summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorBnyro <bnyro@tutanota.com>2025-05-25 11:49:04 +0200
committerMarkus Heiser <markus.heiser@darmarIT.de>2025-05-25 18:04:18 +0200
commit9dfdd30da0c5d13398947fce0c35fc996552f8f6 (patch)
tree4401a272b96bece51a36ecdc1fa37d40c5b94e4b /client
parent14b8a999f3929975756ed6f9dc33c54977b5cedc (diff)
[fix] search: autocomplete focus on results page
This has been a regression introduced with the removal of the unmaintained autocomplete.js library. We should only focus the search bar on the main search page at `/` and not at the results page located at `/search`. I'm not sure if there's a better way to figure out if we're on the results page than checking if the id of the main element is `#main_results`, checking the path obviously isn't a better solution because it can differ depending on the instance / reverse proxy / .... - related to https://github.com/searxng/searxng/commit/32823ecb69b115a6726475d6421f0a1c0327fafa - closes https://github.com/searxng/searxng/issues/4846
Diffstat (limited to 'client')
-rw-r--r--client/simple/src/js/main/search.js3
1 files changed, 2 insertions, 1 deletions
diff --git a/client/simple/src/js/main/search.js b/client/simple/src/js/main/search.js
index 99062fc40..c252dfdb5 100644
--- a/client/simple/src/js/main/search.js
+++ b/client/simple/src/js/main/search.js
@@ -7,6 +7,7 @@
var qinput_id = "q", qinput;
const isMobile = window.matchMedia("only screen and (max-width: 50em)").matches;
+ const isResultsPage = document.querySelector("main").id == "main_results";
function submitIfQuery () {
if (qinput.value.length > 0) {
@@ -87,7 +88,7 @@
searxng.ready(function () {
// focus search input on large screens
- if (!isMobile) document.getElementById("q").focus();
+ if (!isMobile && !isResultsPage) document.getElementById("q").focus();
qinput = d.getElementById(qinput_id);
const autocomplete = d.querySelector(".autocomplete");