fix: macOS menu item accelerators when item disabled (#49593)

fix: macOS menu item acceerators when item disabled

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
trop[bot]
2026-01-30 14:52:17 -05:00
committed by GitHub
parent f36da597ff
commit fd4f835f37

View File

@@ -484,8 +484,11 @@ NSArray* ConvertSharingItemToNS(const SharingItem& item) {
if (index < 0 || index >= count)
return;
// When the menu is closed, we need to allow shortcuts to be triggered even
// if the menu item is disabled. So we only disable the menu item when the
// menu is open. This matches behavior of |validateUserInterfaceItem|.
item.enabled = model->IsEnabledAt(index) || !isMenuOpen_;
item.hidden = !model->IsVisibleAt(index);
item.enabled = model->IsEnabledAt(index);
item.state = model->IsItemCheckedAt(index) ? NSControlStateValueOn
: NSControlStateValueOff;
}
@@ -567,18 +570,19 @@ NSArray* ConvertSharingItemToNS(const SharingItem& item) {
if (!isMenuOpen_)
return;
bool has_close_cb = !popupCloseCallback.is_null();
isMenuOpen_ = NO;
[self refreshMenuTree:menu];
// There are two scenarios where we should emit menu-did-close:
// 1. It's a popup and the top level menu is closed.
// 2. It's an application menu, and the current menu's supermenu
// is the top-level menu.
bool has_close_cb = !popupCloseCallback.is_null();
if (menu != menu_) {
if (has_close_cb || menu.supermenu != menu_)
return;
}
isMenuOpen_ = NO;
if (model_)
model_->MenuWillClose();
// Post async task so that itemSelected runs before the close callback