mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 15:53:27 +00:00
Fix cursor location changing issue on toggle password (#561)
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { Directive, OnInit } from '@angular/core';
|
import { Directive, NgZone, OnInit } from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
import { take } from 'rxjs/operators';
|
||||||
|
|
||||||
import { ApiService } from 'jslib-common/abstractions/api.service';
|
import { ApiService } from 'jslib-common/abstractions/api.service';
|
||||||
import { CryptoService } from 'jslib-common/abstractions/crypto.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 storageService: StorageService, protected vaultTimeoutService: VaultTimeoutService,
|
||||||
protected environmentService: EnvironmentService, protected stateService: StateService,
|
protected environmentService: EnvironmentService, protected stateService: StateService,
|
||||||
protected apiService: ApiService, private logService: LogService,
|
protected apiService: ApiService, private logService: LogService,
|
||||||
private keyConnectorService: KeyConnectorService) { }
|
private keyConnectorService: KeyConnectorService, private ngZone: NgZone) { }
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
this.pinSet = await this.vaultTimeoutService.isPinLockSet();
|
this.pinSet = await this.vaultTimeoutService.isPinLockSet();
|
||||||
@@ -185,7 +186,12 @@ export class LockComponent implements OnInit {
|
|||||||
|
|
||||||
togglePassword() {
|
togglePassword() {
|
||||||
this.showPassword = !this.showPassword;
|
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) {
|
private async setKeyAndContinue(key: SymmetricCryptoKey) {
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
import {
|
import {
|
||||||
Directive,
|
Directive,
|
||||||
Input,
|
Input,
|
||||||
|
NgZone,
|
||||||
OnInit,
|
OnInit,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
|
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
|
||||||
|
import { take } from 'rxjs/operators';
|
||||||
|
|
||||||
import { AuthResult } from 'jslib-common/models/domain/authResult';
|
import { AuthResult } from 'jslib-common/models/domain/authResult';
|
||||||
|
|
||||||
import { AuthService } from 'jslib-common/abstractions/auth.service';
|
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 stateService: StateService, environmentService: EnvironmentService,
|
||||||
protected passwordGenerationService: PasswordGenerationService,
|
protected passwordGenerationService: PasswordGenerationService,
|
||||||
protected cryptoFunctionService: CryptoFunctionService, private storageService: StorageService,
|
protected cryptoFunctionService: CryptoFunctionService, private storageService: StorageService,
|
||||||
protected logService: LogService) {
|
protected logService: LogService, private ngZone: NgZone) {
|
||||||
super(environmentService, i18nService, platformUtilsService);
|
super(environmentService, i18nService, platformUtilsService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,7 +135,11 @@ export class LoginComponent extends CaptchaProtectedComponent implements OnInit
|
|||||||
|
|
||||||
togglePassword() {
|
togglePassword() {
|
||||||
this.showPassword = !this.showPassword;
|
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) {
|
async launchSsoBrowser(clientId: string, ssoRedirectUri: string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user