From 7d3266f775e490d9255e1177ca2167ddc6b71d9d Mon Sep 17 00:00:00 2001 From: Andreas Roussos Date: Fri, 26 Jul 2024 13:12:01 +0000 Subject: [PATCH] Bug 33668: (follow-up) Ensure the clear button is added to the DOM only once Every time the OPAC search dropdown menu is used to select a specific search type (by keyword/Title/Author/ISBN/etc.), the 'Clear search' button HTML code is re-added to the DOM. This has the side effect of multiple presses of the 'X' button being required in order to hide it. Test plan: 1) Without this patch applied, use the dropdown menu adjacent to the OPAC search box to select a specific search type. Make, for example, 3 changes in a row (because you can't make up your mind). 2) Type something in the search box: notice that the 'X' button appears. Now click on the 'X' button: notice that it doesn't go away immediately, but requires as many clicks as the number of times you selected a search type in step 1. 3) Apply the patch and perform a hard refresh (CTRL+F5) on the OPAC main page to reload all JavaScript assets. 4) Repeat steps 1 and 2 -- this time the 'X' button should hide itself immediately when you first click on it. Signed-off-by: Roman Dolny --- koha-tmpl/opac-tmpl/bootstrap/js/global.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/global.js b/koha-tmpl/opac-tmpl/bootstrap/js/global.js index 5fbbc2c077..fe26a15b94 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/js/global.js +++ b/koha-tmpl/opac-tmpl/bootstrap/js/global.js @@ -253,7 +253,11 @@ function setPlaceholder(){ let search_placeholder = $("#masthead_search option:selected").data("placeholder"); let clearButton = $(''); - $("#translControl1").attr("placeholder", search_placeholder).after(clearButton); + $("#translControl1").attr("placeholder", search_placeholder); + + if ($(".clear-search").length == 0) { + $("#translControl1").after(clearButton); + } if ($("#translControl1").val() == '') { clearButton.hide(); -- 2.39.2