<label i18n for="username">User</label>
<input
type="text" id="username" i18n-placeholder placeholder="Username or email address" required tabindex="1"
- formControlName="username" class="form-control" [ngClass]="{ 'input-error': formErrors['username'] }" #usernameInput
+ formControlName="username" class="form-control" [ngClass]="{ 'input-error': formErrors['username'] }" autofocus
>
</div>
import { ActivatedRoute } from '@angular/router'
import { AuthService, Notifier, RedirectService, UserService } from '@app/core'
import { HooksService } from '@app/core/plugins/hooks.service'
-import { InstanceAboutAccordionComponent } from '@app/shared/shared-instance'
import { LOGIN_PASSWORD_VALIDATOR, LOGIN_USERNAME_VALIDATOR } from '@app/shared/form-validators/login-validators'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
+import { InstanceAboutAccordionComponent } from '@app/shared/shared-instance'
import { NgbAccordion, NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'
import { RegisteredExternalAuthConfig, ServerConfig } from '@shared/models'
})
export class LoginComponent extends FormReactive implements OnInit, AfterViewInit {
- @ViewChild('usernameInput', { static: false }) usernameInput: ElementRef
@ViewChild('forgotPasswordModal', { static: true }) forgotPasswordModal: ElementRef
accordion: NgbAccordion
}
ngAfterViewInit () {
- if (this.usernameInput) {
- this.usernameInput.nativeElement.focus()
- }
-
this.hooks.runAction('action:login.init', 'login')
}
--- /dev/null
+import { AfterViewInit, Directive, ElementRef } from '@angular/core'
+
+@Directive({
+ selector: '[autofocus]'
+})
+export class AutofocusDirective implements AfterViewInit {
+ constructor (private host: ElementRef) { }
+
+ ngAfterViewInit () {
+ this.host.nativeElement.focus()
+ }
+}
import { SharedGlobalIconModule } from '../shared-icons'
import { AccountService, ActorAvatarInfoComponent, VideoAvatarChannelComponent } from './account'
import {
+ AutofocusDirective,
BytesPipe,
DurationFormatterPipe,
FromNowPipe,
NumberFormatterPipe,
BytesPipe,
DurationFormatterPipe,
+ AutofocusDirective,
InfiniteScrollerDirective,
PeerTubeTemplateDirective,
BytesPipe,
NumberFormatterPipe,
DurationFormatterPipe,
+ AutofocusDirective,
InfiniteScrollerDirective,
PeerTubeTemplateDirective,