1
0
mirror of https://github.com/bitwarden/jslib synced 2025-12-14 23:33:36 +00:00

Fix cursor location changing issue on toggle password (#561)

This commit is contained in:
Yuan Chao
2021-11-29 05:30:32 +08:00
committed by GitHub
parent d02fcd082e
commit 920ec05fbb
3 changed files with 18 additions and 5 deletions

View File

@@ -1,11 +1,14 @@
import {
Directive,
Input,
NgZone,
OnInit,
} from '@angular/core';
import { Router } from '@angular/router';
import { take } from 'rxjs/operators';
import { AuthResult } from 'jslib-common/models/domain/authResult';
import { AuthService } from 'jslib-common/abstractions/auth.service';
@@ -51,7 +54,7 @@ export class LoginComponent extends CaptchaProtectedComponent implements OnInit
protected stateService: StateService, environmentService: EnvironmentService,
protected passwordGenerationService: PasswordGenerationService,
protected cryptoFunctionService: CryptoFunctionService, private storageService: StorageService,
protected logService: LogService) {
protected logService: LogService, private ngZone: NgZone) {
super(environmentService, i18nService, platformUtilsService);
}
@@ -132,7 +135,11 @@ export class LoginComponent extends CaptchaProtectedComponent implements OnInit
togglePassword() {
this.showPassword = !this.showPassword;
document.getElementById('masterPassword').focus();
if (this.ngZone.isStable) {
document.getElementById('masterPassword').focus();
} else {
this.ngZone.onStable.pipe(take(1)).subscribe(() => document.getElementById('masterPassword').focus());
}
}
async launchSsoBrowser(clientId: string, ssoRedirectUri: string) {