Skip to content

Commit 051e109

Browse files
does enter enter search on random char
1 parent f0dab8b commit 051e109

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/html_support_files/odoc_search.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,6 @@ function focus_next_result() {
105105
results[current_focus + 1].focus();
106106
}
107107

108-
function enter_focus() {
109-
if (n_focus === null) return;
110-
let elt = current_result();
111-
elt.click();
112-
}
113108

114109
function is_searching() {
115110
return (document.querySelectorAll(".odoc-search:focus-within").length > 0);
@@ -140,12 +135,13 @@ function handle_key_down(event) {
140135
event.preventDefault();
141136
enter_search();
142137
}
143-
else if ( event.key.length === 1
144-
&& (ascii >= 65 && ascii <= 90) // lowercase letter
145-
|| (ascii >= 97 && ascii <= 122) // uppercase letter
146-
|| (ascii >= 48 && ascii <= 57) // numbers
147-
|| (ascii >= 32 && ascii <= 46) // ` ` to `.`
148-
|| (ascii >= 58 && ascii <= 64) // `:` to `@`
138+
else if ( is_searching()
139+
&& event.key.length === 1
140+
&& ( (ascii >= 65 && ascii <= 90) // lowercase letter
141+
|| (ascii >= 97 && ascii <= 122) // uppercase letter
142+
|| (ascii >= 48 && ascii <= 57) // numbers
143+
|| (ascii >= 32 && ascii <= 46) // ` ` to `.`
144+
|| (ascii >= 58 && ascii <= 64)) // `:` to `@`
149145
)
150146
// We do not prevent default because we want the char to be added to the input
151147
enter_search ();

0 commit comments

Comments
 (0)