mirror of
https://github.com/bitwarden/browser
synced 2025-12-18 17:23:37 +00:00
[macOS] Don't enable secure input when app is not in focus (#970)
* Don't engage macOS secure input if not focused * Refactor to use focusInputOnPageLoad * Fix style and linting * Refactor to remove focusOnPageLoad * Update jslib
This commit is contained in:
@@ -33,6 +33,8 @@ const BroadcasterSubscriptionId = 'LockComponent';
|
||||
templateUrl: 'lock.component.html',
|
||||
})
|
||||
export class LockComponent extends BaseLockComponent implements OnDestroy {
|
||||
private deferFocus: boolean = null;
|
||||
|
||||
constructor(router: Router, i18nService: I18nService,
|
||||
platformUtilsService: PlatformUtilsService, messagingService: MessagingService,
|
||||
userService: UserService, cryptoService: CryptoService,
|
||||
@@ -63,10 +65,22 @@ export class LockComponent extends BaseLockComponent implements OnDestroy {
|
||||
case 'windowHidden':
|
||||
this.onWindowHidden();
|
||||
break;
|
||||
case 'windowIsFocused':
|
||||
if (this.deferFocus === null) {
|
||||
this.deferFocus = !message.windowIsFocused;
|
||||
if (!this.deferFocus) {
|
||||
this.focusInput();
|
||||
}
|
||||
} else if (this.deferFocus && message.windowIsFocused) {
|
||||
this.focusInput();
|
||||
this.deferFocus = false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
}
|
||||
});
|
||||
});
|
||||
this.messagingService.send('getWindowIsFocused');
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
@@ -76,4 +90,8 @@ export class LockComponent extends BaseLockComponent implements OnDestroy {
|
||||
onWindowHidden() {
|
||||
this.showPassword = false;
|
||||
}
|
||||
|
||||
private focusInput() {
|
||||
document.getElementById(this.pinLock ? 'pin' : 'masterPassword').focus();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user