Commit bebb6a45a5

Linus Groh <mail@linusgroh.de>
2023-05-13 18:52:13
autodoc: Start search on any search input event, not just keydown
1 parent 4652729
Changed files (1)
lib
docs
lib/docs/main.js
@@ -133,6 +133,7 @@ const NAV_MODES = {
 
   domSearch.disabled = false;
   domSearch.addEventListener("keydown", onSearchKeyDown, false);
+  domSearch.addEventListener("input", onSearchInput, false);
   domSearch.addEventListener("focus", ev => {
     domSearchPlaceholder.classList.add("hidden");
     canToggleHelpModal = false;
@@ -4009,15 +4010,17 @@ function addDeclToSearchResults(decl, declIndex, modNames, item, list, stack) {
         ev.stopPropagation();
         return;
       default:
-        if (ev.shiftKey || ev.ctrlKey || ev.altKey) return;
-
-        curSearchIndex = -1;
+        // Search is triggered via an `input` event handler, not on arbitrary `keydown` events.
         ev.stopPropagation();
-        startAsyncSearch();
         return;
     }
   }
 
+  function onSearchInput(ev) {
+    curSearchIndex = -1;
+    startAsyncSearch();
+  }
+
   function moveSearchCursor(dir) {
     if (
       curSearchIndex < 0 ||