[MM-62581] Prevent URL view from ever taking focus by always returning focus to the current server view (#3303)

This commit is contained in:
Devin Binnie
2025-01-31 10:31:47 -05:00
committed by GitHub
parent 17300dfd4a
commit 6c17001e76

View File

@@ -362,6 +362,14 @@ export class ViewManager {
const localURL = `mattermost-desktop://renderer/urlView.html?url=${encodeURIComponent(urlString)}`; const localURL = `mattermost-desktop://renderer/urlView.html?url=${encodeURIComponent(urlString)}`;
performanceMonitor.registerView('URLView', urlView.webContents); performanceMonitor.registerView('URLView', urlView.webContents);
urlView.webContents.loadURL(localURL); 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); MainWindow.get()?.contentView.addChildView(urlView);
const boundaries = this.views.get(this.currentView || '')?.getBounds() ?? MainWindow.getBounds(); const boundaries = this.views.get(this.currentView || '')?.getBounds() ?? MainWindow.getBounds();