autofocus first field on login
authorRigel Kent <sendmemail@rigelk.eu>
Sat, 22 Sep 2018 12:14:32 +0000 (14:14 +0200)
committerRigel Kent <sendmemail@rigelk.eu>
Sat, 22 Sep 2018 12:14:32 +0000 (14:14 +0200)
client/src/app/login/login.component.html
client/src/app/login/login.component.ts

index 619150adeab9ee68376ecda60c0ba8d39b7d8d5e..267a2d857336be29abe0d9aa5a0b674040b56cc1 100644 (file)
@@ -13,7 +13,7 @@
         <label i18n for="username">User</label>
         <input
           type="text" id="username" i18n-placeholder placeholder="Username or email address" required tabindex="1"
-          formControlName="username" [ngClass]="{ 'input-error': formErrors['username'] }"
+          formControlName="username" [ngClass]="{ 'input-error': formErrors['username'] }" #emailInput
         >
         <a i18n *ngIf="signupAllowed === true" routerLink="/signup" class="create-an-account">
           or create an account
index 7c02208859508562344d9911ddbb19a58ea73655..4bae3ae5c950b9347c9584ad406c401d13ec8a36 100644 (file)
@@ -16,6 +16,7 @@ import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'
 })
 
 export class LoginComponent extends FormReactive implements OnInit {
+  @ViewChild('emailInput') input: ElementRef
   @ViewChild('forgotPasswordModal') forgotPasswordModal: ElementRef
   @ViewChild('forgotPasswordEmailInput') forgotPasswordEmailInput: ElementRef
 
@@ -47,6 +48,8 @@ export class LoginComponent extends FormReactive implements OnInit {
       username: this.loginValidatorsService.LOGIN_USERNAME,
       password: this.loginValidatorsService.LOGIN_PASSWORD
     })
+
+    this.input.nativeElement.focus()
   }
 
   login () {