From 6d1377d78ff73728a19170ec04e3d855cdf93295 Mon Sep 17 00:00:00 2001 From: SandObserver <260779319+SandObserver@users.noreply.github.com> Date: Thu, 24 Sep 2026 17:46:07 -0400 Subject: [PATCH] Fix search results opening two tabs on click --- ui/index.html | 2 +- ui/js/dashboard.js | 2 +- ui/js/spotlight.js | 9 +++++---- ui/test/spotlight-dismiss.test.mjs | 7 +++++++ 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/ui/index.html b/ui/index.html index 7492b861..88e57ddd 100644 --- a/ui/index.html +++ b/ui/index.html @@ -55,5 +55,5 @@ - + diff --git a/ui/js/dashboard.js b/ui/js/dashboard.js index 8ab6161c..4fc21014 100644 --- a/ui/js/dashboard.js +++ b/ui/js/dashboard.js @@ -26,7 +26,7 @@ import { titleWhenTruncated, } from '/js/utils.js?v=ed0f1802'; import { initFluidHover } from '/js/fluid-hover.js?v=cb886e86'; -import { initSpotlight } from '/js/spotlight.js?v=6cac6066'; +import { initSpotlight } from '/js/spotlight.js?v=2d911c06'; import { html, setHtml, raw } from '/js/html.js?v=c71f8903'; import { initI18n, t, currentLang } from '/js/i18n.js?v=1f1ea9c1'; import { pwStrength, passwordMismatch } from '/js/password-strength.js?v=42f45ac7'; diff --git a/ui/js/spotlight.js b/ui/js/spotlight.js index 321e2f61..9590d2d6 100644 --- a/ui/js/spotlight.js +++ b/ui/js/spotlight.js @@ -65,7 +65,8 @@ export function initSpotlight({ getItems, isMob, CB, iconChain, openFolderDeskto a.setAttribute('aria-selected', i === 0 ? 'true' : 'false'); a.style.cssText = 'display:flex;align-items:center;gap:18px;padding:14px 20px;text-decoration:none;cursor:pointer;-webkit-tap-highlight-color:transparent;'; - const doOpen = () => { + /* A click also follows the link. Opening here as well opens two tabs. */ + const doOpen = viaTouch => { close(); if (isFolder) { if (MOB()) { @@ -74,15 +75,15 @@ export function initSpotlight({ getItems, isMob, CB, iconChain, openFolderDeskto } else openFolderDesktop(app); } else if (app.system === 'settings' && app.href) { window.location.href = app.href; - } else if (app.href) { + } else if (viaTouch && app.href) { window.open(app.href, '_blank', 'noreferrer,noopener'); } }; a.addEventListener('touchend', e => { e.preventDefault(); - doOpen(); + doOpen(true); }); - a.onclick = doOpen; + a.onclick = () => doOpen(false); const ic = mk('div'); ic.className = 'sri'; diff --git a/ui/test/spotlight-dismiss.test.mjs b/ui/test/spotlight-dismiss.test.mjs index fc55868b..505e001d 100644 --- a/ui/test/spotlight-dismiss.test.mjs +++ b/ui/test/spotlight-dismiss.test.mjs @@ -107,3 +107,10 @@ test('the browser is asked to resize the page for the keyboard', () => { test('the list drops the status-bar inset once the keyboard has moved it', () => { assert.match(css, /body\.is-mob #spot\.kb #sres \{[^}]*padding-top:12px/); }); + +test('a click on a result leaves the new tab to the link', () => { + assert.match(js, /target: isInternal \? '_self' : '_blank'/); + assert.match(js, /\} else if \(viaTouch && app\.href\) \{\s*window\.open\(/); + assert.match(js, /a\.onclick = \(\) => doOpen\(false\);/); + assert.match(js, /e\.preventDefault\(\);\s*doOpen\(true\);/); +});