From fd4f835f377fc44da38e55b75df2bcc7e962d051 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Fri, 30 Jan 2026 14:52:17 -0500 Subject: [PATCH] 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 --- shell/browser/ui/cocoa/electron_menu_controller.mm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/shell/browser/ui/cocoa/electron_menu_controller.mm b/shell/browser/ui/cocoa/electron_menu_controller.mm index 844ca12c31..94334af9c2 100644 --- a/shell/browser/ui/cocoa/electron_menu_controller.mm +++ b/shell/browser/ui/cocoa/electron_menu_controller.mm @@ -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