1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-11 05:43:41 +00:00

AC-1267 - (1) Mark master pass (MP) field as untouched on any load of 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)

This commit is contained in:
Jared Snider
2023-04-25 10:08:58 -04:00
committed by GitHub
parent 1b9c4a9c11
commit 85277aa2f8

View File

@@ -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();
});
}
}
}