mirror of
https://github.com/iv-org/invidious.git
synced 2026-07-28 08:26:49 -05:00
Fix error when searchbox is missing and move minimum character requirement
This commit is contained in:
parent
9b62062eba
commit
4a57c21609
@ -11,7 +11,7 @@ function resetSuggestions() {
|
||||
selectedSuggestion = -1;
|
||||
}
|
||||
|
||||
searchbox.addEventListener("input", function () {
|
||||
searchbox?.addEventListener("input", function () {
|
||||
// If there is already a request in progress,
|
||||
// abort. The user has made another input,
|
||||
// invalidating the old query.
|
||||
@ -19,13 +19,6 @@ searchbox.addEventListener("input", function () {
|
||||
suggestionController.abort();
|
||||
}
|
||||
|
||||
// Only continue for queries of at least
|
||||
// one character.
|
||||
if (searchbox.value.length < 2) {
|
||||
resetSuggestions();
|
||||
return;
|
||||
}
|
||||
|
||||
// Only make a request for suggestions after
|
||||
// there is a delay of at least 150 milliseconds
|
||||
// between inputs.
|
||||
@ -36,6 +29,13 @@ searchbox.addEventListener("input", function () {
|
||||
return;
|
||||
}
|
||||
|
||||
// Only continue for queries of at least
|
||||
// one character.
|
||||
if (searchbox.value.length < 2) {
|
||||
resetSuggestions();
|
||||
return;
|
||||
}
|
||||
|
||||
// Create the controller which will be
|
||||
// used to abort this request if another
|
||||
// is made before it finishes.
|
||||
@ -74,7 +74,7 @@ searchbox.addEventListener("input", function () {
|
||||
}, 150);
|
||||
});
|
||||
|
||||
searchbox.addEventListener("keydown", function (e) {
|
||||
searchbox?.addEventListener("keydown", function (e) {
|
||||
const currentSuggestions = suggestions.children;
|
||||
|
||||
// Navigate suggestions by key.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user