Don't open recent searches on start-up focus; no auto-focus on touch devices

This commit is contained in:
Jonathan Sykes
2026-10-15 11:15:40 +08:00
parent 007e5b5352
commit 6f62c8c139

View File

@@ -7961,7 +7961,10 @@ function wireUI() {
els.searchRecent.classList.remove('hidden');
}
function hideRecentSearches() { els.searchRecent.classList.add('hidden'); }
els.searchInput.addEventListener('focus', showRecentSearches);
// Only a user's own focus opens the list, never the start-up focus below.
els.searchInput.addEventListener('focus', () => { if (!els.searchInput._bootFocus) showRecentSearches(); });
// Already focused (start-up) — a click or tap on the box still opens it.
els.searchInput.addEventListener('pointerdown', () => { if (document.activeElement === els.searchInput) showRecentSearches(); });
els.searchInput.addEventListener('input', () => {
if (els.searchInput.value.trim()) hideRecentSearches(); else showRecentSearches();
});
@@ -9440,7 +9443,12 @@ async function boot() {
checkAutoBackup();
render();
els.searchInput.focus();
// Ready to type on desktop; on touch devices focusing would pop the keyboard.
if (!matchMedia('(pointer: coarse)').matches) {
els.searchInput._bootFocus = true;
els.searchInput.focus({ preventScroll: true });
els.searchInput._bootFocus = false;
}
// Register service worker + ping server with fingerprint (WEB mode only)
if (WEB) checkUpdateOutcome();