From 2de364e0b709f0f9293e66470a8b24b0be1ff295 Mon Sep 17 00:00:00 2001
From: Sam Johnson <sam@scj.me>
Date: Tue, 20 Aug 2024 17:21:02 +0000
Subject: [PATCH] Bug 1899943 - Show menupopup gutter on macOS only when an
 item is selected/checked.  a=RyanVM

In bug 1668119, I adjusted macOS menupopups to only show a gutter if the menu contains either items that are checkboxes or radios, or checked/selected items of any type. However, this was not quite correct. In native macOS menus, a gutter is only shown if there is a checked/selected item--even if there are checkbox items, there should not be a gutter if no item is checked/selected. This patch matches that behavior.

Original Revision: https://phabricator.services.mozilla.com/D212217

Differential Revision: https://phabricator.services.mozilla.com/D219586
---
 toolkit/content/widgets/menupopup.js | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/toolkit/content/widgets/menupopup.js b/toolkit/content/widgets/menupopup.js
index c7448d4f05798..49d61ed561cd3 100644
--- a/toolkit/content/widgets/menupopup.js
+++ b/toolkit/content/widgets/menupopup.js
@@ -19,11 +19,11 @@
       // radio/checkbox type menuitems in a menupopup when showing it.
       if (e.target.nodeName == "menupopup") {
         let haveCheckableChild = e.target.querySelector(
-          `:scope > menuitem:not([hidden]):is([type=checkbox],[type=radio]${
+          `:scope > menuitem:not([hidden]):is(${
             // On macOS, selected menuitems are checked regardless of type
             AppConstants.platform == "macosx"
-              ? ",[checked=true],[selected=true]"
-              : ""
+              ? "[checked=true],[selected=true]"
+              : "[type=checkbox],[type=radio]"
           })`
         );
         e.target.toggleAttribute("needsgutter", haveCheckableChild);
-- 
GitLab