[mod] Update input when selecting by TAB

When the user press [TAB] the input form should be filled with the highlighted
item from the autocomplete list, but not release a search / with other words:
what we now have by pressing once on [ENTER] should be mapped to the [TAB] key
and pressing [ENTER] once should release a search query. [1]

[1] https://github.com/searxng/searxng/issues/778#issuecomment-1016593816

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
Markus Heiser 2023-04-10 15:42:11 +02:00
parent e9fb9f2705
commit 962b4c719f

View file

@ -82,6 +82,21 @@
} }
}, },
}), }),
"Tab": Object.assign({}, AutoComplete.defaults.KeyboardMappings.Enter, {
Conditions: [{
Is: 9,
Not: false
}],
Callback: function (event) {
if (this.DOMResults.getAttribute("class").indexOf("open") != -1) {
var liActive = this.DOMResults.querySelector("li.active");
if (liActive !== null) {
AutoComplete.defaults._Select.call(this, liActive);
event.preventDefault();
}
}
},
})
}), }),
}, "#" + qinput_id); }, "#" + qinput_id);
} }