From 0519a119d7cd69307513de58fd49c19866651ff9 Mon Sep 17 00:00:00 2001 From: Devin Binnie <52460000+devinbinnie@users.noreply.github.com> Date: Fri, 30 Jun 2023 11:46:44 -0400 Subject: [PATCH] [MM-50536] Add workaround for Dev Tools not opening correctly on Mac (#2777) --- src/main/views/MattermostBrowserView.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/views/MattermostBrowserView.ts b/src/main/views/MattermostBrowserView.ts index 5506fb77..3cd1bca8 100644 --- a/src/main/views/MattermostBrowserView.ts +++ b/src/main/views/MattermostBrowserView.ts @@ -293,6 +293,21 @@ export class MattermostBrowserView extends EventEmitter { } openDevTools = () => { + // Workaround for a bug with our Dev Tools on Mac + // For some reason if you open two Dev Tools windows and close the first one, it won't register the closing + // So what we do here is check to see if it's opened correctly and if not we reset it + if (process.platform === 'darwin') { + const timeout = setTimeout(() => { + if (this.browserView.webContents.isDevToolsOpened()) { + this.browserView.webContents.closeDevTools(); + this.browserView.webContents.openDevTools({mode: 'detach'}); + } + }, 500); + this.browserView.webContents.on('devtools-opened', () => { + clearTimeout(timeout); + }); + } + this.browserView.webContents.openDevTools({mode: 'detach'}); }