diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2025-01-10 18:45:44 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2025-01-10 18:51:27 -0400 |
commit | 085ab0e889f1a3182dffb9f48cf33aff013f22ec (patch) | |
tree | ab69f13562514bfed564f1da888218feadbf5809 | |
parent | b05383e49bc1de21997321afb468905eb7cefb1d (diff) |
client: cancel focus first search result when text cursor moves
HTMLInputElement: selectionchange still not available, boo hoo although this is probably appropriate wrt selection moving literally anywhere else - should also cancel focus-first-result
-rw-r--r-- | src/static/js/client/sidebar-search.js | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/static/js/client/sidebar-search.js b/src/static/js/client/sidebar-search.js index 10ccf1b5..c79fb837 100644 --- a/src/static/js/client/sidebar-search.js +++ b/src/static/js/client/sidebar-search.js @@ -376,6 +376,15 @@ export function addPageListeners() { } }); + document.addEventListener('selectionchange', _domEvent => { + const {state} = info; + + if (state.focusFirstResultTimeout) { + clearTimeout(state.focusFirstResultTimeout); + state.focusFirstResultTimeout = null; + } + }); + info.endSearchLink.addEventListener('click', domEvent => { domEvent.preventDefault(); clearSidebarSearch(); |