[autocomplete] allow enter to do the default thing

This commit is contained in:
Shish 2024-02-04 00:24:34 +00:00
parent 143ca4820e
commit 74889c4c94

View file

@ -232,16 +232,11 @@ document.addEventListener('DOMContentLoaded', () => {
event.preventDefault();
highlightCompletion(element, element.selected_completion+1);
}
// if enter or right are pressed, add the selected completion
// if enter or right are pressed while a completion is selected, add the selected completion
else if((event.code === "Enter" || event.code == "ArrowRight") && element.selected_completion !== -1) {
event.preventDefault();
setCompletion(element, Object.keys(element.completions)[element.selected_completion]);
}
// If enter is pressed while nothing is selected, submit the form
else if(event.code === "Enter" && element.selected_completion === -1) {
event.preventDefault();
element.form.submit();
}
// if escape is pressed, hide the completion block
else if(event.code === "Escape") {
event.preventDefault();