authorgravatar for mail@linusgroh.deLinus Groh <mail@linusgroh.de> 2023-05-13 17:52:13+01:00
committergravatar for mail@linusgroh.deLinus Groh <mail@linusgroh.de> 2023-05-13 17:52:13+01:00
logbebb6a45a5e439ded35d2451e3575b2839884810
treedbcce6c2e550a9797ec5f64ca991e8aaa1a0d6b6
parent46527292178d64daa9f81be3eef378d78d254b5d

autodoc: Start search on any search input event, not just keydown


1 files changed, 7 insertions(+), 4 deletions(-)

lib/docs/main.js+7-4
...@@ -133,6 +133,7 @@ const NAV_MODES = {...@@ -133,6 +133,7 @@ const NAV_MODES = {
133133
134 domSearch.disabled = false;134 domSearch.disabled = false;
135 domSearch.addEventListener("keydown", onSearchKeyDown, false);135 domSearch.addEventListener("keydown", onSearchKeyDown, false);
136 domSearch.addEventListener("input", onSearchInput, false);
136 domSearch.addEventListener("focus", ev => {137 domSearch.addEventListener("focus", ev => {
137 domSearchPlaceholder.classList.add("hidden");138 domSearchPlaceholder.classList.add("hidden");
138 canToggleHelpModal = false;139 canToggleHelpModal = false;
...@@ -4009,15 +4010,17 @@ function addDeclToSearchResults(decl, declIndex, modNames, item, list, stack) {...@@ -4009,15 +4010,17 @@ function addDeclToSearchResults(decl, declIndex, modNames, item, list, stack) {
4009 ev.stopPropagation();4010 ev.stopPropagation();
4010 return;4011 return;
4011 default:4012 default:
4012 if (ev.shiftKey || ev.ctrlKey || ev.altKey) return;4013 // Search is triggered via an `input` event handler, not on arbitrary `keydown` events.
4013
4014 curSearchIndex = -1;
4015 ev.stopPropagation();4014 ev.stopPropagation();
4016 startAsyncSearch();
4017 return;4015 return;
4018 }4016 }
4019 }4017 }
40204018
4019 function onSearchInput(ev) {
4020 curSearchIndex = -1;
4021 startAsyncSearch();
4022 }
4023
4021 function moveSearchCursor(dir) {4024 function moveSearchCursor(dir) {
4022 if (4025 if (
4023 curSearchIndex < 0 ||4026 curSearchIndex < 0 ||