From 99a84a0fd70335e1b2d44d7f85786b1bf7ec90e4 Mon Sep 17 00:00:00 2001 From: Devin Binnie <52460000+devinbinnie@users.noreply.github.com> Date: Mon, 6 Mar 2023 11:49:15 -0500 Subject: [PATCH] [GH-2534] Refocus the popup window if already exists (#2581) * [GH-2534] Refocus the popup window if already exists * PR feedback --------- Co-authored-by: Mattermost Build --- src/main/views/webContentEvents.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/views/webContentEvents.ts b/src/main/views/webContentEvents.ts index e7c808a5..61d0473b 100644 --- a/src/main/views/webContentEvents.ts +++ b/src/main/views/webContentEvents.ts @@ -199,27 +199,26 @@ export class WebContentsEventManager { } }); this.popupWindow.webContents.setWindowOpenHandler(this.denyNewWindow); - this.popupWindow.once('ready-to-show', () => { - this.popupWindow!.show(); - }); this.popupWindow.once('closed', () => { this.popupWindow = undefined; }); + const contextMenu = new ContextMenu({}, this.popupWindow); + contextMenu.reload(); } + const popupWindow = this.popupWindow; + popupWindow.once('ready-to-show', () => popupWindow.show()); + if (urlUtils.isManagedResource(serverURL, parsedURL)) { - this.popupWindow.loadURL(details.url); + popupWindow.loadURL(details.url); } else { // currently changing the userAgent for popup windows to allow plugins to go through google's oAuth // should be removed once a proper oAuth2 implementation is setup. - this.popupWindow.loadURL(details.url, { + popupWindow.loadURL(details.url, { userAgent: composeUserAgent(), }); } - const contextMenu = new ContextMenu({}, this.popupWindow); - contextMenu.reload(); - return {action: 'deny'}; }