From b05383e49bc1de21997321afb468905eb7cefb1d Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 10 Jan 2025 18:44:56 -0400 Subject: client: simplify logic to cancel focus first result --- src/static/js/client/sidebar-search.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/static') diff --git a/src/static/js/client/sidebar-search.js b/src/static/js/client/sidebar-search.js index 2e34baad..10ccf1b5 100644 --- a/src/static/js/client/sidebar-search.js +++ b/src/static/js/client/sidebar-search.js @@ -106,7 +106,7 @@ export const info = { stoppedTypingDelay: 800, stoppedScrollingDelay: 200, - pressDownToFocusFirstResultLatency: 200, + pressDownToFocusFirstResultLatency: 500, dismissChangeEventAfterFocusingFirstResultLatency: 50, maxActiveResultsStorage: 100000, @@ -339,6 +339,11 @@ export function addPageListeners() { state.stoppedTypingTimeout = null; activateSidebarSearch(info.searchInput.value); }, settings.stoppedTypingDelay); + + if (state.focusFirstResultTimeout) { + clearTimeout(state.focusFirstResultTimeout); + state.focusFirstResultTimeout = null; + } }); info.searchInput.addEventListener('drop', handleDroppedIntoSearchInput); @@ -495,9 +500,7 @@ async function activateSidebarSearch(query) { if (state.focusFirstResultTimeout) { clearTimeout(state.focusFirstResultTimeout); state.focusFirstResultTimeout = null; - if (!state.stoppedTypingTimeout) { - focusFirstSidebarSearchResult(); - } + focusFirstSidebarSearchResult(); } } -- cgit 1.3.0-6-gf8a5