diff --git a/browser/base/content/browser-pageActions.js b/browser/base/content/browser-pageActions.js index 1e1c278f350b..6c1a630e33c0 100644 --- a/browser/base/content/browser-pageActions.js +++ b/browser/base/content/browser-pageActions.js @@ -48,6 +48,24 @@ var BrowserPageActions = { */ init() { this.placeAllActions(); + + // Add a click listener to #page-action-buttons for blocking clicks on + // disabled actions in the urlbar. Normally we'd do this by setting + // `pointer-events: none` in the CSS, but that also blocks context menu + // events, and we want the context menu even on disabled actions so that + // they can be removed from the urlbar. + this.mainButtonNode.parentNode.addEventListener("click", event => { + if (event.button == 2) { + // Let context-clicks be handled normally. + return; + } + let node = event.originalTarget; + let action = this.actionForNode(node); + if (action && action.getDisabled(window)) { + event.preventDefault(); + event.stopPropagation(); + } + }, true); }, /** @@ -128,6 +146,7 @@ var BrowserPageActions = { "subviewbutton-iconic", "pageAction-panel-button" ); + buttonNode.setAttribute("actionid", action.id); if (action.nodeAttributes) { for (let name in action.nodeAttributes) { buttonNode.setAttribute(name, action.nodeAttributes[name]); @@ -391,8 +410,8 @@ var BrowserPageActions = { _makeUrlbarButtonNode(action) { let buttonNode = document.createElement("image"); buttonNode.classList.add("urlbar-icon", "urlbar-page-action"); + buttonNode.setAttribute("actionid", action.id); buttonNode.setAttribute("role", "button"); - buttonNode.setAttribute("context", "pageActionPanelContextMenu"); buttonNode.addEventListener("contextmenu", event => { BrowserPageActions.onContextMenu(event); }); diff --git a/browser/base/content/browser.css b/browser/base/content/browser.css index ee29c6ed6401..6f832a74dcae 100644 --- a/browser/base/content/browser.css +++ b/browser/base/content/browser.css @@ -1443,11 +1443,6 @@ toolbarpaletteitem[place="palette"][hidden] { } } -.urlbar-page-action[disabled] { - pointer-events: none; - -moz-user-focus: ignore; -} - /* WebExtension Sidebars */ #sidebar-box[sidebarcommand$="-sidebar-action"] > #sidebar-header > #sidebar-switcher-target > #sidebar-icon { list-style-image: var(--webextension-menuitem-image, inherit); diff --git a/browser/base/content/browser.xul b/browser/base/content/browser.xul index a2ee06501af5..f844226a180e 100644 --- a/browser/base/content/browser.xul +++ b/browser/base/content/browser.xul @@ -421,7 +421,7 @@ mainViewId="pageActionPanelMainView" viewCacheId="appMenu-viewCache"> @@ -444,9 +444,9 @@