Skip to content

fix: refresh menu item state on key equivalent dispatch#49875

Merged
jkleinsc merged 1 commit intomainfrom
fix-menu-item-enabled-shortcut-harder
Feb 20, 2026
Merged

fix: refresh menu item state on key equivalent dispatch#49875
jkleinsc merged 1 commit intomainfrom
fix-menu-item-enabled-shortcut-harder

Conversation

@codebytere
Copy link
Copy Markdown
Member

@codebytere codebytere commented Feb 19, 2026

Description of Change

Closes #49841
Refs #49549
Refs #48598

With autoenablesItems = NO, macOS doesn't re-validate menu items while the menu is closed. Previously this was worked around by forcing item.enabled = YES when closed || !isMenuOpen_, which meant shortcuts could fire even for intentionally disabled items.

This replaces that workaround with menuNeedsUpdate:, which AppKit calls both before displaying a menu and during key equivalent matching — even while closed. This ensures item state is always synced from the model before AppKit decides whether to dispatch.

Also removes the now-redundant refreshMenuTree: calls in menuWillOpen:/menuDidClose:.

Checklist

Release Notes

Notes: Fixed an issue where menu item enabled state wasn't updated during key equivalent dispatch when the menu was closed on macOS.

@codebytere codebytere added semver/patch backwards-compatible bug fixes target/39-x-y PR should also be added to the "39-x-y" branch. target/40-x-y PR should also be added to the "40-x-y" branch. target/41-x-y PR should also be added to the "41-x-y" branch. labels Feb 19, 2026
@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label Feb 19, 2026
Copy link
Copy Markdown
Member

@ckerr ckerr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice cleanup!

@electron-cation electron-cation Bot removed the new-pr 🌱 PR opened recently label Feb 20, 2026
@jkleinsc jkleinsc merged commit 3e58c6c into main Feb 20, 2026
78 checks passed
@jkleinsc jkleinsc deleted the fix-menu-item-enabled-shortcut-harder branch February 20, 2026 16:35
@release-clerk
Copy link
Copy Markdown

release-clerk Bot commented Feb 20, 2026

Release Notes Persisted

Fixed an issue where menu item enabled state wasn't updated during key equivalent dispatch when the menu was closed on macOS.

@trop
Copy link
Copy Markdown
Contributor

trop Bot commented Feb 20, 2026

I have automatically backported this PR to "39-x-y", please check out #49888

@trop trop Bot added in-flight/39-x-y and removed target/39-x-y PR should also be added to the "39-x-y" branch. labels Feb 20, 2026
@trop
Copy link
Copy Markdown
Contributor

trop Bot commented Feb 20, 2026

I have automatically backported this PR to "40-x-y", please check out #49889

@trop
Copy link
Copy Markdown
Contributor

trop Bot commented Feb 20, 2026

I have automatically backported this PR to "41-x-y", please check out #49890

@trop trop Bot added in-flight/40-x-y in-flight/41-x-y merged/41-x-y PR was merged to the "41-x-y" branch. merged/40-x-y PR was merged to the "40-x-y" branch. and removed target/40-x-y PR should also be added to the "40-x-y" branch. target/41-x-y PR should also be added to the "41-x-y" branch. in-flight/41-x-y in-flight/40-x-y labels Feb 20, 2026
@trop trop Bot added merged/39-x-y PR was merged to the "39-x-y" branch. and removed in-flight/39-x-y labels Feb 20, 2026
kycutler pushed a commit to kycutler/electron that referenced this pull request Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged/39-x-y PR was merged to the "39-x-y" branch. merged/40-x-y PR was merged to the "40-x-y" branch. merged/41-x-y PR was merged to the "41-x-y" branch. semver/patch backwards-compatible bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MenuItem accelerators fire even with enabled: false action

3 participants