1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-12 22:33:35 +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,5 +1,6 @@
import { Directive, OnInit } from '@angular/core';
import { Directive, NgZone, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { take } from 'rxjs/operators';
import { ApiService } from 'jslib-common/abstractions/api.service';
import { CryptoService } from 'jslib-common/abstractions/crypto.service';
@@ -51,7 +52,7 @@ export class LockComponent implements OnInit {
protected storageService: StorageService, protected vaultTimeoutService: VaultTimeoutService,
protected environmentService: EnvironmentService, protected stateService: StateService,
protected apiService: ApiService, private logService: LogService,
private keyConnectorService: KeyConnectorService) { }
private keyConnectorService: KeyConnectorService, private ngZone: NgZone) { }
async ngOnInit() {
this.pinSet = await this.vaultTimeoutService.isPinLockSet();
@@ -185,7 +186,12 @@ export class LockComponent implements OnInit {
togglePassword() {
this.showPassword = !this.showPassword;
document.getElementById(this.pinLock ? 'pin' : 'masterPassword').focus();
const input = document.getElementById(this.pinLock ? 'pin' : 'masterPassword');
if (this.ngZone.isStable) {
input.focus();
} else {
this.ngZone.onStable.pipe(take(1)).subscribe(() => input.focus());
}
}
private async setKeyAndContinue(key: SymmetricCryptoKey) {