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

Signed-off-by: Emmanuel Bétemps <e.betemps@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 14c25fe64e)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
Jake Deery 2025-09-09 09:44:43 +00:00 committed by Paul Derscheid
parent fe12e361f9
commit 1591869c08
No known key found for this signature in database
GPG Key ID: C25F9FD44CED595B
1 changed files with 21 additions and 4 deletions

View File

@ -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();
}
});
</script>
[% END %]