feat: support middle-click on bookmark open buttons

This commit is contained in:
2026-03-02 16:56:48 +01:00
parent 7ee22b6c8f
commit 438c0ce77c
3 changed files with 41 additions and 5 deletions

View File

@@ -1512,6 +1512,32 @@ function openBookmarkQueries(baseQuery) {
return opened;
}
function bindMiddleMouseOpen(element, handler) {
if (!element || typeof handler !== 'function') {
return;
}
// Prevent browser auto-scroll so middle click behaves like link-open here.
element.addEventListener('mousedown', (event) => {
if (event.button === 1) {
event.preventDefault();
}
});
element.addEventListener('auxclick', (event) => {
if (event.button !== 1) {
return;
}
event.preventDefault();
event.stopPropagation();
handler();
});
}
if (typeof window !== 'undefined') {
window.bindMiddleMouseOpen = bindMiddleMouseOpen;
}
function openBookmark(bookmark) {
if (!bookmark) {
return;
@@ -1611,7 +1637,9 @@ function createBookmarkRow(bookmark) {
openButton.title = searchVariants.map((variant) => `${variant}`).join('\n');
}
openButton.addEventListener('click', () => openBookmark(bookmark));
const handleOpenBookmark = () => openBookmark(bookmark);
openButton.addEventListener('click', handleOpenBookmark);
bindMiddleMouseOpen(openButton, handleOpenBookmark);
const label = document.createElement('span');
label.className = 'bookmark-row__label';