Bug 1395871 - Open pageAction menus on mousedown, rather than oncommand. draft
authorZibi Braniecki <zbraniecki@mozilla.com>
Tue, 05 Sep 2017 21:38:07 -0700
changeset 659673 a9a76dee545da282b3919c8f043d6e1a55651b6b
parent 659672 22acda504cb17f847a0696b02428c4264c18f442
child 730013 da733f8408b5af02097e5a3e445c47257aebf4de
push id78154
push userbmo:gandalf@aviary.pl
push dateWed, 06 Sep 2017 04:47:44 +0000
bugs1395871
milestone57.0a1
Bug 1395871 - Open pageAction menus on mousedown, rather than oncommand. MozReview-Commit-ID: 7i2kHcpZOPf
browser/base/content/browser-pageActions.js
--- a/browser/base/content/browser-pageActions.js
+++ b/browser/base/content/browser-pageActions.js
@@ -355,17 +355,24 @@ var BrowserPageActions = {
     buttonNode.addEventListener("contextmenu", event => {
       BrowserPageActions.onContextMenu(event);
     });
     if (action.nodeAttributes) {
       for (let name in action.nodeAttributes) {
         buttonNode.setAttribute(name, action.nodeAttributes[name]);
       }
     }
-    buttonNode.addEventListener("click", event => {
+
+    // The `activationEvent` should be `mousedown` if the only
+    // result of the click is the opening of a submenu.
+    //
+    // If the button has an additional action, this code will need to
+    // get additional parameter to recognize which event to use.
+    const activationEvent = action.subview ? "mousedown" : "click";
+    buttonNode.addEventListener(activationEvent, event => {
       if (event.button != 0) {
         return;
       }
       if (action.subview || action.wantsIframe) {
         this._toggleActivatedActionPanelForAction(action);
         return;
       }
       action.onCommand(event, buttonNode);