fix: stop menu minimization if set false (#46715)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Michaela Laurencin <mlaurencin@electronjs.org>
This commit is contained in:
parent
6e56fed2cb
commit
f6f9e23fe2
2 changed files with 20 additions and 2 deletions
|
@ -78,7 +78,9 @@ export const roleList: Record<RoleId, Role> = {
|
||||||
minimize: {
|
minimize: {
|
||||||
label: 'Minimize',
|
label: 'Minimize',
|
||||||
accelerator: 'CommandOrControl+M',
|
accelerator: 'CommandOrControl+M',
|
||||||
windowMethod: w => w.minimize()
|
windowMethod: w => {
|
||||||
|
if (w.minimizable) w.minimize();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
paste: {
|
paste: {
|
||||||
label: 'Paste',
|
label: 'Paste',
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { BrowserWindow, app, Menu, MenuItem, MenuItemConstructorOptions } from '
|
||||||
|
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
|
|
||||||
import { ifdescribe } from './lib/spec-helpers';
|
import { ifit, ifdescribe } from './lib/spec-helpers';
|
||||||
import { closeAllWindows } from './lib/window-helpers';
|
import { closeAllWindows } from './lib/window-helpers';
|
||||||
import { roleList, execute } from '../lib/browser/api/menu-item-roles';
|
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);
|
const canExecute = execute(item.role as any, win, win.webContents);
|
||||||
expect(canExecute).to.be.true('can execute');
|
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', () => {
|
describe('MenuItem command id', () => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue