feat: Open new tab on middle click in tab bar

This commit adds the ability to open a new tab by middle-clicking the tab bar.

The functionality is implemented by adding an event listener for the "mouseup" event on the tab bar and checking if the middle mouse button was clicked. If so, it calls the `BrowserCommands.openTab()` function to open a new tab and prevents the default behavior of the event.
This commit is contained in:
Kristijan Ribarić
2024-10-03 20:08:29 +02:00
parent 33531e973b
commit f5863391fe

View File

@@ -84,6 +84,20 @@ var gZenVerticalTabsManager = {
gZenCompactModeManager.addEventListener(updateEvent);
this._updateEvent();
this.initRightSideOrderContextMenu();
let tabs = document.getElementById("tabbrowser-tabs");
if (tabs) {
tabs.addEventListener("mouseup", this.openNewTabOnTabsMiddleClick.bind(this));
}
},
openNewTabOnTabsMiddleClick(event) {
if (event.button === 1 && event.target.id === "tabbrowser-tabs") {
BrowserCommands.openTab({ event });
event.stopPropagation();
event.preventDefault();
}
},
get navigatorToolbox() {