Fix autocomplete behavior on result page

Similar issue to #629, but the result page uses a different script for
handling user input, so the fix was not applied appropriately.

It has been fixed for this view now.
main
Ben Busby 2022-06-09 16:40:49 -06:00
parent 65796fd1a5
commit 35ac5ac82f
No known key found for this signature in database
GPG Key ID: B9B7231E01D924A1
1 changed files with 7 additions and 4 deletions

View File

@ -1,11 +1,14 @@
document.addEventListener("DOMContentLoaded", () => { document.addEventListener("DOMContentLoaded", () => {
const searchBar = document.getElementById("search-bar"); const searchBar = document.getElementById("search-bar");
const arrowKeys = [37, 38, 39, 40];
let searchValue = searchBar.value;
searchBar.addEventListener("keyup", function (event) { searchBar.addEventListener("keyup", function(event) {
if (event.keyCode !== 13) { if (event.keyCode === 13) {
handleUserInput(searchBar);
} else {
document.getElementById("search-form").submit(); document.getElementById("search-form").submit();
} else if (searchBar.value !== searchValue && !arrowKeys.includes(event.keyCode)) {
searchValue = searchBar.value;
handleUserInput();
} }
}); });
}); });