From 085ab0e889f1a3182dffb9f48cf33aff013f22ec Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 10 Jan 2025 18:45:44 -0400 Subject: 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 --- src/static/js/client/sidebar-search.js | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/static/js/client/sidebar-search.js') 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(); -- cgit 1.3.0-6-gf8a5