Bug 1377967 - make middle clicking history, bookmarks and closed tabs items work correctly, r?mikedeboer draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Thu, 10 Aug 2017 23:05:33 +0100
changeset 644716 2f246591e20979033bf2c66d29080f1c43f9c9a1
parent 644701 81ce957220904ab446aef23baecc4b7877c50025
child 725699 4956d4963bb3693359929562c745313c18c125b2
push id73534
push usergijskruitbosch@gmail.com
push dateFri, 11 Aug 2017 09:31:08 +0000
reviewersmikedeboer
bugs1377967
milestone57.0a1
Bug 1377967 - make middle clicking history, bookmarks and closed tabs items work correctly, r?mikedeboer MozReview-Commit-ID: VQUuQHyCXi
browser/components/places/content/browserPlacesViews.js
browser/components/sessionstore/RecentlyClosedTabsAndWindowsMenuUtils.jsm
--- a/browser/components/places/content/browserPlacesViews.js
+++ b/browser/components/places/content/browserPlacesViews.js
@@ -2015,29 +2015,34 @@ this.PlacesPanelview = class extends Pla
     this._onPopupShowing({ originalTarget: this._rootElt });
     this._addEventListeners(window, ["unload"]);
     this._rootElt.setAttribute("context", "placesContext");
   }
 
   get events() {
     if (this._events)
       return this._events;
-    return this._events = ["command", "dragend", "dragstart", "ViewHiding", "ViewShown"];
+    return this._events = ["click", "command", "dragend", "dragstart", "ViewHiding", "ViewShown"];
   }
 
   get panel() {
     return this.panelMultiView.parentNode;
   }
 
   get panelMultiView() {
     return this._viewElt.panelMultiView;
   }
 
   handleEvent(event) {
     switch (event.type) {
+      case "click":
+        // For left and middle clicks, fall through to the command handler.
+        if (event.button >= 2) {
+          break;
+        }
       case "command":
         this._onCommand(event);
         break;
       case "dragend":
         this._onDragEnd(event);
         break;
       case "dragstart":
         this._onDragStart(event);
@@ -2055,16 +2060,17 @@ this.PlacesPanelview = class extends Pla
   }
 
   _onCommand(event) {
     let button = event.originalTarget;
     if (!button._placesNode)
       return;
 
     PlacesUIUtils.openNodeWithEvent(button._placesNode, event);
+    this.panelMultiView.closest("panel").hidePopup();
   }
 
   _onDragEnd() {
     this._draggedElt = null;
   }
 
   _onDragStart(event) {
     let draggedElt = event.originalTarget;
--- a/browser/components/sessionstore/RecentlyClosedTabsAndWindowsMenuUtils.jsm
+++ b/browser/components/sessionstore/RecentlyClosedTabsAndWindowsMenuUtils.jsm
@@ -105,16 +105,20 @@ this.RecentlyClosedTabsAndWindowsMenuUti
     *        The event when the user clicks the menu item
     */
   _undoCloseMiddleClick(aEvent) {
     if (aEvent.button != 1)
       return;
 
     aEvent.view.undoCloseTab(aEvent.originalTarget.getAttribute("value"));
     aEvent.view.gBrowser.moveTabToEnd();
+    let ancestorPanel = aEvent.target.closest("panel");
+    if (ancestorPanel) {
+      ancestorPanel.hidePopup();
+    }
   },
 };
 
 function setImage(aItem, aElement) {
   let iconURL = aItem.image;
   // don't initiate a connection just to fetch a favicon (see bug 467828)
   if (/^https?:/.test(iconURL))
     iconURL = "moz-anno:favicon:" + iconURL;