Bug 1377967 - make middle clicking history, bookmarks and closed tabs items work correctly, r?mikedeboer
MozReview-Commit-ID: VQUuQHyCXi
--- 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;