From 962b4c719fa7ca32470fa4d092130c3d27c2d45f Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Mon, 10 Apr 2023 15:42:11 +0200 Subject: [PATCH] [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 --- searx/static/themes/simple/src/js/main/search.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/searx/static/themes/simple/src/js/main/search.js b/searx/static/themes/simple/src/js/main/search.js index ceb17958b..cb2a9d882 100644 --- a/searx/static/themes/simple/src/js/main/search.js +++ b/searx/static/themes/simple/src/js/main/search.js @@ -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); }