diff --git a/src/main/views/viewManager.ts b/src/main/views/viewManager.ts index d7bb9571..d6b539e8 100644 --- a/src/main/views/viewManager.ts +++ b/src/main/views/viewManager.ts @@ -362,6 +362,14 @@ export class ViewManager { const localURL = `mattermost-desktop://renderer/urlView.html?url=${encodeURIComponent(urlString)}`; performanceMonitor.registerView('URLView', urlView.webContents); urlView.webContents.loadURL(localURL); + + // This is a workaround for an issue where the URL view would steal focus from the main window + // See: https://github.com/electron/electron/issues/42339 + urlView.webContents.on('focus', () => { + log.debug('URL view focus prevented'); + this.getCurrentView()?.focus(); + }); + MainWindow.get()?.contentView.addChildView(urlView); const boundaries = this.views.get(this.currentView || '')?.getBounds() ?? MainWindow.getBounds();