fix(electron): active view sometimes does not get focused (#8683)
This commit is contained in:
@@ -171,22 +171,6 @@ export function createApplicationMenu() {
|
|||||||
switchToPreviousTab();
|
switchToPreviousTab();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
label: 'Switch to next tab (mac)',
|
|
||||||
accelerator: 'Command+]',
|
|
||||||
visible: false,
|
|
||||||
click: () => {
|
|
||||||
switchToNextTab();
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Switch to previous tab (mac)',
|
|
||||||
accelerator: 'Command+[',
|
|
||||||
visible: false,
|
|
||||||
click: () => {
|
|
||||||
switchToPreviousTab();
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
label: 'Switch to next tab (mac 2)',
|
label: 'Switch to next tab (mac 2)',
|
||||||
accelerator: 'Alt+Command+]',
|
accelerator: 'Alt+Command+]',
|
||||||
|
|||||||
@@ -734,6 +734,33 @@ export class WebContentViewsManager {
|
|||||||
app.on('before-quit', () => {
|
app.on('before-quit', () => {
|
||||||
disposables.forEach(d => d.unsubscribe());
|
disposables.forEach(d => d.unsubscribe());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const focusActiveView = () => {
|
||||||
|
if (
|
||||||
|
!this.activeWorkbenchView ||
|
||||||
|
this.activeWorkbenchView.webContents.isFocused()
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.activeWorkbenchView?.webContents.focus();
|
||||||
|
setTimeout(() => {
|
||||||
|
focusActiveView();
|
||||||
|
}, 100);
|
||||||
|
};
|
||||||
|
|
||||||
|
app.on('browser-window-focus', () => {
|
||||||
|
focusActiveView();
|
||||||
|
});
|
||||||
|
|
||||||
|
combineLatest([
|
||||||
|
this.activeWorkbenchId$,
|
||||||
|
this.mainWindowManager.mainWindow$,
|
||||||
|
]).subscribe(([_, window]) => {
|
||||||
|
// makes sure the active view is always focused
|
||||||
|
if (window?.isFocused()) {
|
||||||
|
focusActiveView();
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
getViewById = (id: string) => {
|
getViewById = (id: string) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user