Skip to content

Commit

Permalink
AC-1267 - (1) Mark master pass (MP) field as untouched on any load of…
Browse files Browse the repository at this point in the history
… MP section of login page post email validation in order to prevent validation errors of "input required" from being shown prematurely before the user has entered anything or lost focus on the input when the user hits enter on the login screen after entering an email (2) Improve the logic around the MP autofocus to match existing code patterns to ensure there are no possible scenarios in which the MP would not be autofocused. (#5246)
  • Loading branch information
JaredSnider-Bitwarden committed Apr 25, 2023
1 parent 1b9c4a9 commit 85277aa
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions libs/angular/src/auth/components/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,19 @@ export class LoginComponent extends CaptchaProtectedComponent implements OnInit
// so that autofill can work properly
this.formGroup.controls.masterPassword.reset();
} else {
// Mark MP as untouched so that, when users enter email and hit enter,
// the MP field doesn't load with validation errors
this.formGroup.controls.masterPassword.markAsUntouched();

// When email is validated, focus on master password after
// waiting for input to be rendered
this.ngZone.onStable
.pipe(take(1))
.subscribe(() => this.masterPasswordInput?.nativeElement?.focus());
if (this.ngZone.isStable) {
this.masterPasswordInput?.nativeElement?.focus();
} else {
this.ngZone.onStable.pipe(take(1)).subscribe(() => {
this.masterPasswordInput?.nativeElement?.focus();
});
}
}
}

Expand Down

0 comments on commit 85277aa

Please sign in to comment.