From 6f6b5a5503b7aeb7bbd174e3f96a33ce1c9a8037 Mon Sep 17 00:00:00 2001 From: Thomas Rittson <31796059+eliykat@users.noreply.github.com> Date: Fri, 2 Jul 2021 10:06:54 +1000 Subject: [PATCH] [macOS] Don't enable secure input when app is not in focus (#419) * Don't engage macOS secure input if not focused * Refactor to use focusInputOnPageLoad * Refactor to remove focusInputOnPageLoad --- angular/src/components/login.component.ts | 8 ++++++-- electron/src/window.main.ts | 6 ++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/angular/src/components/login.component.ts b/angular/src/components/login.component.ts index 61b66c56e8..22c9736a93 100644 --- a/angular/src/components/login.component.ts +++ b/angular/src/components/login.component.ts @@ -58,8 +58,8 @@ export class LoginComponent implements OnInit { if (this.rememberEmail == null) { this.rememberEmail = true; } - if (Utils.isBrowser) { - document.getElementById(this.email == null || this.email === '' ? 'email' : 'masterPassword').focus(); + if (Utils.isBrowser && !Utils.isNode) { + this.focusInput(); } } @@ -143,4 +143,8 @@ export class LoginComponent implements OnInit { '&redirectUri=' + encodeURIComponent(ssoRedirectUri) + '&state=' + state + '&codeChallenge=' + codeChallenge); } + + protected focusInput() { + document.getElementById(this.email == null || this.email === '' ? 'email' : 'masterPassword').focus(); + } } diff --git a/electron/src/window.main.ts b/electron/src/window.main.ts index b8a42aea81..a7c542bb4a 100644 --- a/electron/src/window.main.ts +++ b/electron/src/window.main.ts @@ -174,6 +174,12 @@ export class WindowMain { this.win.on('move', () => { this.windowStateChangeHandler(Keys.mainWindowSize, this.win); }); + this.win.on('focus', () => { + this.win.webContents.send('messagingService', { + command: 'windowIsFocused', + windowIsFocused: true, + }); + }); if (this.createWindowCallback) { this.createWindowCallback(this.win);