fix: menu should allow focused BaseWindow where possible (#43439)

fix: menu should allow focused BaseWindow

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
trop[bot] 2024-08-22 18:33:44 -05:00 committed by GitHub
parent 557d5c901a
commit a373ab027b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 25 additions and 19 deletions

View file

@ -1,4 +1,4 @@
import { BaseWindow, MenuItem, webContents, Menu as MenuType, BrowserWindow, MenuItemConstructorOptions } from 'electron/main';
import { BaseWindow, MenuItem, webContents, Menu as MenuType, MenuItemConstructorOptions } from 'electron/main';
import { sortMenuItems } from '@electron/internal/browser/api/menu-utils';
import { setApplicationMenuWasSet } from '@electron/internal/browser/default-menu';
@ -54,7 +54,7 @@ Menu.prototype._executeCommand = function (event, id) {
const command = this.commandsMap[id];
if (!command) return;
const focusedWindow = BaseWindow.getFocusedWindow();
command.click(event, focusedWindow instanceof BrowserWindow ? focusedWindow : undefined, webContents.getFocusedWebContents());
command.click(event, focusedWindow, webContents.getFocusedWebContents());
};
Menu.prototype._menuWillShow = function () {