diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2025-01-10 18:44:56 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2025-01-10 18:51:27 -0400 |
commit | b05383e49bc1de21997321afb468905eb7cefb1d (patch) | |
tree | 5299c12116145c0e82e712e8f79bc046ec5273ef /src/static | |
parent | 1eaa19ecac9affb7f6a7c0e6c6363c125ece91cf (diff) |
client: simplify logic to cancel focus first result
Diffstat (limited to 'src/static')
-rw-r--r-- | src/static/js/client/sidebar-search.js | 11 |
1 files changed, 7 insertions, 4 deletions
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(); } } |