Prevent Menu.buildFromTemplate with empty array
fix: prevent Menu.buildFromTemplate with empty array (#23308)
Prevent Menu.buildFromTemplate with empty arrayfixprevent menu buildfromtemplate empty array
Committed by codebytere
commit message
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.Editor assessment
The subject states the guard precisely: Menu.buildFromTemplate rejected for an empty array. The fix type is right. The body is exemplary: it explains the user-visible harm — menu creation and pane-focus problems — argues why no valid use case exists since removal paths like setMenu with null already cover intent, and scopes the exception deliberately to top-level menus because submenus are unaffected. That is motivation, alternative, and design boundary in one paragraph. Hygiene is clean throughout. An exemplar-level message that teaches how to think about the API, not just what changed.