mirror of
https://github.com/searxng/searxng.git
synced 2025-07-09 03:04:26 -04:00
[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 32823ecb69
- closes https://github.com/searxng/searxng/issues/4846
This commit is contained in:
parent
14b8a999f3
commit
9dfdd30da0
@ -7,6 +7,7 @@
|
|||||||
var qinput_id = "q", qinput;
|
var qinput_id = "q", qinput;
|
||||||
|
|
||||||
const isMobile = window.matchMedia("only screen and (max-width: 50em)").matches;
|
const isMobile = window.matchMedia("only screen and (max-width: 50em)").matches;
|
||||||
|
const isResultsPage = document.querySelector("main").id == "main_results";
|
||||||
|
|
||||||
function submitIfQuery () {
|
function submitIfQuery () {
|
||||||
if (qinput.value.length > 0) {
|
if (qinput.value.length > 0) {
|
||||||
@ -87,7 +88,7 @@
|
|||||||
|
|
||||||
searxng.ready(function () {
|
searxng.ready(function () {
|
||||||
// focus search input on large screens
|
// focus search input on large screens
|
||||||
if (!isMobile) document.getElementById("q").focus();
|
if (!isMobile && !isResultsPage) document.getElementById("q").focus();
|
||||||
|
|
||||||
qinput = d.getElementById(qinput_id);
|
qinput = d.getElementById(qinput_id);
|
||||||
const autocomplete = d.querySelector(".autocomplete");
|
const autocomplete = d.querySelector(".autocomplete");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user