#49553: fix: macOS menu item accelerators when item disabled
Description of Change
Fixes an issue where menu item accelerators stopped working after the item's enabled property was toggled.
To fix this we keep menu items enabled for shortcut purposes when the menu is closed, and only apply the disabled state when the menu is visually open. This mirrors the behavior of validateUserInterfaceItem, which would have handled this automatically in the menu.autoenablesItems = YES; case. When the menu closes, we now call refreshMenuTree to re-enable items for keyboard shortcut handling.
Tested with https://gist.github.com/4cad43fe183393ff57a0b46ac55bfbf3.
Checklist
- PR description included
-
npm testpasses - PR release notes describe the change in a way relevant to app developers, and are capitalized, punctuated, and past tense.
Release Notes
Notes: Fixed an issue where menu item accelerators stopped working after the item's enabled property was toggled on macOS.
Backports
Semver Impact
Semantic Versioning helps users understand the impact of updates:
- Major (X.y.z): Breaking changes that may require code modifications
- Minor (x.Y.z): New features that maintain backward compatibility
- Patch (x.y.Z): Bug fixes that don't change the API
- None: Changes that don't affect using facing parts of Electron