From 84340f56ec0b33019fe623eb1ddf3742a874aabe Mon Sep 17 00:00:00 2001 From: Alexandre Flament Date: Sat, 19 Mar 2022 20:37:15 +0100 Subject: [PATCH] simple theme: JS version: the reset button clear the text The introduced in the PR 894, restores the default value. It works in the index page, but it doesn't work in the /search page: the reset button restore the initial query. This PR: * fix the JS version: the reset button clear the text * keep the clear button in the / page * hide the clear button in the /search page --- searx/static/themes/simple/src/js/main/search.js | 3 ++- searx/static/themes/simple/src/less/search.less | 4 ++++ searx/templates/simple/search.html | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/searx/static/themes/simple/src/js/main/search.js b/searx/static/themes/simple/src/js/main/search.js index 6ef95f5bf..1fb0a7cb8 100644 --- a/searx/static/themes/simple/src/js/main/search.js +++ b/searx/static/themes/simple/src/js/main/search.js @@ -31,10 +31,11 @@ // update status, event listener updateClearButton(); - cs.addEventListener('click', function () { + cs.addEventListener('click', function (ev) { qinput.value = ''; qinput.focus(); updateClearButton(); + ev.preventDefault(); }); qinput.addEventListener('keyup', updateClearButton, false); } diff --git a/searx/static/themes/simple/src/less/search.less b/searx/static/themes/simple/src/less/search.less index a9a00d585..62fda55b7 100644 --- a/searx/static/themes/simple/src/less/search.less +++ b/searx/static/themes/simple/src/less/search.less @@ -125,6 +125,10 @@ } } +html.no-js #clear_search.hide_if_nojs { + display: none; +} + #q, #send_search { display: block !important; diff --git a/searx/templates/simple/search.html b/searx/templates/simple/search.html index 8c64211e5..a26af3e5d 100644 --- a/searx/templates/simple/search.html +++ b/searx/templates/simple/search.html @@ -6,7 +6,7 @@ {% set display_tooltip = true %}