From a8524b11c0a08f68c5fdd139330f067b79fe758d Mon Sep 17 00:00:00 2001 From: Andreas Roussos Date: Wed, 14 Jun 2023 14:00:15 +0000 Subject: [PATCH] Bug 34005: Move button toggling code outside JS for loop When OpacHighlightedWords is set to "Highlight", if you search in the OPAC and the number of keywords is odd (1, 3, 5, etc.), then the "Unhighlight" / "Highlight" button will stop working after a couple of clicks. The relevant commit is 9cb89b46397 from v20.11.00, where the code responsible for toggling the "Unhighlight" / "Highlight" button was moved inside the JS for loop that cycles through each term in the array of search terms. This explains why the toggling only works when an even number of search terms is being used. This patch fixes that, by placing the button toggling code in its original position (outside the JavaScript for loop of the highlightOn() function). Test plan: 0) If required, set OpacHighlightedWords to "Highlight". 1) Search for "history" in the OPAC, and view the details page of one of the results. Click on the "Unhighlight" button a few times -- after a couple of clicks the button text will stop toggling and you won't be able to remove the keyword highlight any more. 2) Apply this patch. 3) Repeat step 1): this time you should be able to toggle the search keyword highlighting no matter how many times you click on the "Unhighlight" / "Highlight" button. 4) Repeat step 1), but this time search for "century history": you should be able to toggle search keyword highlighting in the details page on and off repeatedly without any problems. Signed-off-by: Lucas Gass Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 55f3eb3919b282dd3adf7c584b57158b8eed8c25) Signed-off-by: Martin Renvoize (cherry picked from commit 3a550c39cb0dfef068b29ad58ecae2fc2f9480fb) Signed-off-by: Matt Blenkinsop --- koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt index d4a5b5cc62..87b1d58f13 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt @@ -1493,8 +1493,8 @@ $(".results_summary").highlight(q_array[x]); } } - $(".highlight_toggle").toggle(); } + $(".highlight_toggle").toggle(); } [% END # /IF OpacHighlightedWords %] -- 2.39.5