fix: prevent Menu.buildFromTemplate with empty array (#23308)
Prevent issues with menu creation and subsequent pane focus from menu bar by preventing menus from being created from an empty array. I can't conceive a valid use case for this, since if one wants to remove a menu they should be be passing null to win.setMenu() or calling win.removeMenu(). This issue is also specific to top-level menus, and not submenus, so the new check and exception is scoped to top-level menus.
This commit is contained in:
parent
448017b9ee
commit
f50f725a9c
3 changed files with 19 additions and 2 deletions
|
@ -16,7 +16,7 @@ const MenuItem = function (options) {
|
|||
}
|
||||
this.submenu = this.submenu || roles.getDefaultSubmenu(this.role);
|
||||
if (this.submenu != null && this.submenu.constructor !== Menu) {
|
||||
this.submenu = Menu.buildFromTemplate(this.submenu);
|
||||
this.submenu = Menu.buildFromTemplate(this.submenu, true);
|
||||
}
|
||||
if (this.type == null && this.submenu != null) {
|
||||
this.type = 'submenu';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue