From c0836e3f133c68ced5b8e9a4fce243f9fa4c5eba Mon Sep 17 00:00:00 2001 From: Jake Deery Date: Tue, 9 Sep 2025 09:44:43 +0000 Subject: [PATCH] Bug 40780: Advsearch ButtonMinus moves focus to next or prev line This patch will cause the ButtonMinus button on each of the advsearch fieldsets to jump the focus to the next or previous line, whichever is available. This is in response to a recent accessibility audit performed by one of our customers. Thanks! TO TEST: a) go to /cgi-bin/koha/opac-search.pl?expanded_options=1 b) click / tab onto the ButtonMinus next to a field, click / press enter c) notice how the focus disappears APPLY PATCH d) repeat steps a-b e) notice how the focus now either goes to the next line (if available) or the previous line (otherwise) SIGN OFF --- .../bootstrap/en/modules/opac-advsearch.tt | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt index 76f779508fb..a4651d0a4e3 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt @@ -614,13 +614,30 @@ thisLine.after(newLine); }); - $(document).on("click", '.ButtonLess', function(e) { + $(document).on('click', '.ButtonLess', function (e) { e.preventDefault(); - if( $("a.ButtonLess").length <= 2 ) { - $('.ButtonLess').hide(); + if ($('a.ButtonLess').length <= 2) { + $('.ButtonLess').hide(); } + + let first = $(this).parent().parent().first(); + let next = $(this).parent().parent().next(); + let prev = $(this).parent().parent().prev(); + $(this).parent().parent().remove(); - $('.search-term-row .search-term-input select[name="op"]').first().prop("disabled",true).hide(); + $('.search-term-row .search-term-input select[name="op"]').first().prop('disabled', true).hide(); + + let firstInput = first.find(':input:not(:disabled)').first(); + let nextInput = next.find(':input:not(:disabled)').first(); + let prevInput = prev.find(':input:not(:disabled)').first(); + + if (nextInput.length > 0) { + nextInput.focus(); + } else if (prevInput.length > 0) { + prevInput.focus(); + } else { + firstInput.focus(); + } }); [% END %] -- 2.43.0