fix: stop menu minimization if set false (#46279)
This commit is contained in:
parent
274b148554
commit
e383eaa465
2 changed files with 20 additions and 2 deletions
|
@ -78,7 +78,9 @@ export const roleList: Record<RoleId, Role> = {
|
|||
minimize: {
|
||||
label: 'Minimize',
|
||||
accelerator: 'CommandOrControl+M',
|
||||
windowMethod: w => w.minimize()
|
||||
windowMethod: w => {
|
||||
if (w.minimizable) w.minimize();
|
||||
}
|
||||
},
|
||||
paste: {
|
||||
label: 'Paste',
|
||||
|
|
|
@ -2,7 +2,7 @@ import { BrowserWindow, app, Menu, MenuItem, MenuItemConstructorOptions } from '
|
|||
|
||||
import { expect } from 'chai';
|
||||
|
||||
import { ifdescribe } from './lib/spec-helpers';
|
||||
import { ifit, ifdescribe } from './lib/spec-helpers';
|
||||
import { closeAllWindows } from './lib/window-helpers';
|
||||
import { roleList, execute } from '../lib/browser/api/menu-item-roles';
|
||||
|
||||
|
@ -205,6 +205,22 @@ describe('MenuItems', () => {
|
|||
const canExecute = execute(item.role as any, win, win.webContents);
|
||||
expect(canExecute).to.be.true('can execute');
|
||||
});
|
||||
|
||||
ifit(process.platform === 'win32')('does not execute minimize role when minimizable false', () => {
|
||||
const win = new BrowserWindow({ minimizable: false });
|
||||
const menu = Menu.buildFromTemplate([{
|
||||
label: 'text',
|
||||
role: 'minimize'
|
||||
}]);
|
||||
|
||||
Menu.setApplicationMenu(menu);
|
||||
menu._executeCommand({}, menu.items[0].commandId);
|
||||
expect(win.isMinimized()).to.equal(false);
|
||||
|
||||
win.setMinimizable(true);
|
||||
menu._executeCommand({}, menu.items[0].commandId);
|
||||
expect(win.isMinimized()).to.equal(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('MenuItem command id', () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue