Bug 39489 - 'Refine your search' should have an aria-expanded attribute
Summary: 'Refine your search' should have an aria-expanded attribute
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: Accessibility (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Chloé Zermatten
QA Contact: Julian Maurice
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-03-31 09:37 UTC by Chloé Zermatten
Modified: 2025-06-06 08:28 UTC (History)
7 users (show)

See Also:
GIT URL:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
This fixes the "Refine your search" section in the OPAC. For screen reader users on smaller screens, it now correctly announces that it is an expandable section, instead of a link (by adding an aria-expanded attribute). Explanation: The 'Refine your search' expandable section in the Koha OPAC was not clearly announced by screen readers for smaller screen sizes. This is because the expandable section was identified and announced as a link. This resulted in screen reader users incorrectly expecting a link to another page, and not being informed that it was an expandable section.
Version(s) released in:
Circulation function:


Attachments
Bug 39489: 'Refine your search' aria-expanded attribute (4.85 KB, patch)
2025-04-02 11:41 UTC, Chloé Zermatten
Details | Diff | Splinter Review
Bug 39489: 'Refine your search' aria-expanded attribute (4.92 KB, patch)
2025-04-07 19:16 UTC, Brendan Gallagher
Details | Diff | Splinter Review
Bug 39489: 'Refine your search' aria-expanded attribute (5.84 KB, patch)
2025-04-23 13:59 UTC, Chloé Zermatten
Details | Diff | Splinter Review
Bug 39489: 'Refine your search' aria-expanded attribute (5.88 KB, patch)
2025-04-26 19:05 UTC, David Nind
Details | Diff | Splinter Review
Bug 39489: 'Refine your search' aria-expanded attribute (6.73 KB, patch)
2025-05-15 11:58 UTC, Chloé Zermatten
Details | Diff | Splinter Review
Bug 39489: 'Refine your search' aria-expanded attribute (6.77 KB, patch)
2025-05-18 18:59 UTC, David Nind
Details | Diff | Splinter Review
Bug 39489: 'Refine your search' aria-expanded attribute (6.25 KB, patch)
2025-05-22 15:02 UTC, Chloé Zermatten
Details | Diff | Splinter Review
Bug 39489: 'Refine your search' aria-expanded attribute (6.29 KB, patch)
2025-06-06 08:28 UTC, David Nind
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Chloé Zermatten 2025-03-31 09:37:00 UTC
So that screen reader users aren't misled into thinking that the 'Refine Search' section header will take them to another page, add an aria-expanded attribute, and set its value to true if the section is expanded, and false if it is not.

This will clearly mark 'Refine Search' as a collapsible section.
Comment 1 Chloé Zermatten 2025-04-02 11:41:54 UTC
Created attachment 180300 [details] [review]
Bug 39489: 'Refine your search' aria-expanded attribute

On smaller screens (phones, tablets), the 'Refine your search' expandable section in the Koha OPAC is not clearly announced by screen readers.
The reason for this is that the expandable section toggle button is instead identified and announced as a link.
This results in screen reader users incorrectly expecting to be redirected to another page, and not being informed that there is a expandable section.

For elements with a class of menu-collapse-toggle, add an aria-expanded attribute which defaults to false, and is toggled to true upon the section being expanded.

To test:

1) Apply the patch.
2) Run a library catalogue search in the Koha OPAC.
3) Right click on the page to inspect it.
4) Inspect the 'Refine your search' element.
5) Notice that it now has a aria-expanded attribute which is set to false.
6) Open the expandable 'Refine your search' section.
7) Notice that the aria-expanded attribute on the 'Refinine your search' element is now set to true.
8) Navigate to Home > Most popular titles
9) Repeat steps 3-7
10) Navigate to Home > Details for > Full subscription history
11) Repeat steps 3-7
Comment 2 Brendan Gallagher 2025-04-07 19:16:48 UTC
Created attachment 180705 [details] [review]
Bug 39489: 'Refine your search' aria-expanded attribute

On smaller screens (phones, tablets), the 'Refine your search' expandable section in the Koha OPAC is not clearly announced by screen readers.
The reason for this is that the expandable section toggle button is instead identified and announced as a link.
This results in screen reader users incorrectly expecting to be redirected to another page, and not being informed that there is a expandable section.

For elements with a class of menu-collapse-toggle, add an aria-expanded attribute which defaults to false, and is toggled to true upon the section being expanded.

To test:

1) Apply the patch.
2) Run a library catalogue search in the Koha OPAC.
3) Right click on the page to inspect it.
4) Inspect the 'Refine your search' element.
5) Notice that it now has a aria-expanded attribute which is set to false.
6) Open the expandable 'Refine your search' section.
7) Notice that the aria-expanded attribute on the 'Refinine your search' element is now set to true.
8) Navigate to Home > Most popular titles
9) Repeat steps 3-7
10) Navigate to Home > Details for > Full subscription history
11) Repeat steps 3-7

Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>
Comment 3 Julian Maurice 2025-04-18 12:52:45 UTC
1) If I load the page on a large screen, the facets are shown but aria-expanded attribute is "false". Shouldn't it be "true" ? or even removed (since it's not collapsible) ?

2) setAriaExpandable toggles the attribute value for all .menu-collapse-toggle on the page no matter which one is clicked. This isn't a real issue currently as there is only one .menu-collapse-toggle per page, but it could become an issue if other similar sections are introduced, and it can be easily fixed.
Comment 4 Chloé Zermatten 2025-04-22 11:56:56 UTC
(In reply to Julian Maurice from comment #3)
> 1) If I load the page on a large screen, the facets are shown but
> aria-expanded attribute is "false". Shouldn't it be "true" ? or even removed
> (since it's not collapsible) ?
> 
> 2) setAriaExpandable toggles the attribute value for all
> .menu-collapse-toggle on the page no matter which one is clicked. This isn't
> a real issue currently as there is only one .menu-collapse-toggle per page,
> but it could become an issue if other similar sections are introduced, and
> it can be easily fixed.

Thank you for the feedback!
Agreed on both counts, will update the patch to account for both.
Comment 5 Chloé Zermatten 2025-04-23 13:59:48 UTC
Created attachment 181372 [details] [review]
Bug 39489: 'Refine your search' aria-expanded attribute

On smaller screens (phones, tablets), the 'Refine your search' expandable section in the Koha OPAC is not clearly announced by screen readers.
The reason for this is that the expandable section toggle button is instead identified and announced as a link.
This results in screen reader users incorrectly expecting to be redirected to another page, and not being informed that there is a expandable section.

For elements with a class of menu-collapse-toggle, add an aria-expanded attribute which defaults to false, and is toggled to true upon that specific section being expanded.
If the screen width is 992px or higher, then remove the aria-expanded attribute on load as it is irrelevant, and potentially misleading.

To test:

1) Apply the patch.

on a small screen:

2) Run a library catalogue search in the Koha OPAC.
3) Right click on the page to inspect it.
4) Inspect the 'Refine your search' element.
5) Notice that it now has a aria-expanded attribute which is set to false.
6) Open the expandable 'Refine your search' section.
7) Notice that the aria-expanded attribute on the 'Refinine your search' element is now set to true.
8) Navigate to Home > Most popular titles
9) Repeat steps 3-7
10) Navigate to Home > Details for > Full subscription history
11) Repeat steps 3-7

then, on a bigger screen (992px and above)

12) Run a library catalogue search in the Koha OPAC.
13) Right click on the page to inspect it.
14) Inspect the 'Refine your search' element.
15) Notice that there is no 'aria-expanded' attribute, as in this case the section isn't expandable.
Comment 6 David Nind 2025-04-26 19:05:22 UTC
Created attachment 181568 [details] [review]
Bug 39489: 'Refine your search' aria-expanded attribute

On smaller screens (phones, tablets), the 'Refine your search' expandable section in the Koha OPAC is not clearly announced by screen readers.
The reason for this is that the expandable section toggle button is instead identified and announced as a link.
This results in screen reader users incorrectly expecting to be redirected to another page, and not being informed that there is a expandable section.

For elements with a class of menu-collapse-toggle, add an aria-expanded attribute which defaults to false, and is toggled to true upon that specific section being expanded.
If the screen width is 992px or higher, then remove the aria-expanded attribute on load as it is irrelevant, and potentially misleading.

To test:

1) Apply the patch.

on a small screen:

2) Run a library catalogue search in the Koha OPAC.
3) Right click on the page to inspect it.
4) Inspect the 'Refine your search' element.
5) Notice that it now has a aria-expanded attribute which is set to false.
6) Open the expandable 'Refine your search' section.
7) Notice that the aria-expanded attribute on the 'Refinine your search' element is now set to true.
8) Navigate to Home > Most popular titles
9) Repeat steps 3-7
10) Navigate to Home > Details for > Full subscription history
11) Repeat steps 3-7

then, on a bigger screen (992px and above)

12) Run a library catalogue search in the Koha OPAC.
13) Right click on the page to inspect it.
14) Inspect the 'Refine your search' element.
15) Notice that there is no 'aria-expanded' attribute, as in this case the section isn't expandable.

Signed-off-by: David Nind <david@davidnind.com>
Comment 7 David Nind 2025-04-26 19:17:57 UTC
Testing notes (using KTD):

1. To display the "Most popular" link under the search box, set the OpacTopissue system preference to "Allow".

2. To see the full history for a subscription:
   2.1 Set the SubscriptionHistory system preference to "full history".
   2.2 Set up a serial using the serials module (no need to add any items).
   2.3 View the record in the OPAC
   2.4 Select the Subscriptions tab.
   2.5 Click the "More details" link under the latest issues table.
   2.6 You should now be on the full subscription history page for the serial.
Comment 8 Jonathan Druart 2025-05-14 14:33:57 UTC
Not my expertise area but IMO we should not see screen size in JS:

+    if (window.screen.width > 991) {
+        $(".menu-collapse-toggle").removeAttr("aria-expanded");
+    }

Cannot we avoid that?

Do we want the attribute to be adjusted if the window is resized?

Could we have aria-expanded adjusted depending on the arrow visibility?
Comment 9 Chloé Zermatten 2025-05-15 11:58:23 UTC
Created attachment 182489 [details] [review]
Bug 39489: 'Refine your search' aria-expanded attribute

On smaller screens (phones, tablets), the 'Refine your search' expandable section in the Koha OPAC is not clearly announced by screen readers.
The reason for this is that the expandable section toggle button is instead identified and announced as a link.
This results in screen reader users incorrectly expecting to be redirected to another page, and not being informed that there is a expandable section.

For elements with a class of menu-collapse-toggle, add an aria-expanded attribute which defaults to false, and is toggled to true upon that specific section being expanded.
If the screen width is 992px or higher, then remove the aria-expanded attribute on load as it is irrelevant, and potentially misleading.

To test:

1) Apply the patch.

on a small screen:

2) Run a library catalogue search in the Koha OPAC.
3) Right click on the page to inspect it.
4) Inspect the 'Refine your search' element.
5) Notice that it now has a aria-expanded attribute which is set to false.
6) Open the expandable 'Refine your search' section.
7) Notice that the aria-expanded attribute on the 'Refinine your search' element is now set to true.
8) Navigate to Home > Most popular titles
9) Repeat steps 3-7
10) Navigate to Home > Details for > Full subscription history
11) Repeat steps 3-7

then, on a bigger screen (992px and above)

12) Run a library catalogue search in the Koha OPAC.
13) Right click on the page to inspect it.
14) Inspect the 'Refine your search' element.
15) Notice that there is no 'aria-expanded' attribute, as in this case the section isn't expandable.
16) Resize your viewport below 992px, and notice that 'aria-expanded' reappears and is set to false.
17) Resize your viewport while remaining below the 992px limit, and notice that 'aria-expanded' remains set to false.
18) Open 'Refine your search', notice that 'aria-expanded' is set to true.
19) Resize your viewport while remaining below the 992px limit, and notice that 'aria-expanded' remains set to true.

Note: now updated to handle screen resizes
Comment 10 Chloé Zermatten 2025-05-15 12:02:23 UTC
(In reply to Jonathan Druart from comment #8)
> Not my expertise area but IMO we should not see screen size in JS:
> 
> +    if (window.screen.width > 991) {
> +        $(".menu-collapse-toggle").removeAttr("aria-expanded");
> +    }
> 
> Cannot we avoid that?
> 
> Do we want the attribute to be adjusted if the window is resized?
> 
> Could we have aria-expanded adjusted depending on the arrow visibility?

Thank you for the feedback! I had a go at implementing this, hopefully it addresses the points you raised
Comment 11 David Nind 2025-05-18 18:59:21 UTC
Created attachment 182565 [details] [review]
Bug 39489: 'Refine your search' aria-expanded attribute

On smaller screens (phones, tablets), the 'Refine your search' expandable section in the Koha OPAC is not clearly announced by screen readers.
The reason for this is that the expandable section toggle button is instead identified and announced as a link.
This results in screen reader users incorrectly expecting to be redirected to another page, and not being informed that there is a expandable section.

For elements with a class of menu-collapse-toggle, add an aria-expanded attribute which defaults to false, and is toggled to true upon that specific section being expanded.
If the screen width is 992px or higher, then remove the aria-expanded attribute on load as it is irrelevant, and potentially misleading.

To test:

1) Apply the patch.

on a small screen:

2) Run a library catalogue search in the Koha OPAC.
3) Right click on the page to inspect it.
4) Inspect the 'Refine your search' element.
5) Notice that it now has a aria-expanded attribute which is set to false.
6) Open the expandable 'Refine your search' section.
7) Notice that the aria-expanded attribute on the 'Refinine your search' element is now set to true.
8) Navigate to Home > Most popular titles
9) Repeat steps 3-7
10) Navigate to Home > Details for > Full subscription history
11) Repeat steps 3-7

then, on a bigger screen (992px and above)

12) Run a library catalogue search in the Koha OPAC.
13) Right click on the page to inspect it.
14) Inspect the 'Refine your search' element.
15) Notice that there is no 'aria-expanded' attribute, as in this case the section isn't expandable.
16) Resize your viewport below 992px, and notice that 'aria-expanded' reappears and is set to false.
17) Resize your viewport while remaining below the 992px limit, and notice that 'aria-expanded' remains set to false.
18) Open 'Refine your search', notice that 'aria-expanded' is set to true.
19) Resize your viewport while remaining below the 992px limit, and notice that 'aria-expanded' remains set to true.

Note: now updated to handle screen resizes
Signed-off-by: David Nind <david@davidnind.com>
Comment 12 Julian Maurice 2025-05-22 13:28:07 UTC
Comment on attachment 182565 [details] [review]
Bug 39489: 'Refine your search' aria-expanded attribute

Review of attachment 182565 [details] [review]:
-----------------------------------------------------------------

::: koha-tmpl/opac-tmpl/bootstrap/js/results-list.js
@@ +240,4 @@
>          KOHA.Tags.add_tag_button(thisid, tag);
>          return false;
>      });
> +    $(window).on("resize load", function () {

This is not needed: there is already a function (facetMenu) called on load and whenever the screen width goes under or above the break point of 992px (and only in that case, not on every resize)
You should put the aria-expanded logic in facetMenu

@@ +244,5 @@
> +        $(".menu-collapse-toggle").each(function () {
> +            const beforeContent = window.getComputedStyle(
> +                this,
> +                "::before"
> +            ).content;

You should avoid relying on style to define behavior, because whenever the style change it might break functionality.
Comment 13 Chloé Zermatten 2025-05-22 15:02:07 UTC
Created attachment 182735 [details] [review]
Bug 39489: 'Refine your search' aria-expanded attribute

On smaller screens (phones, tablets), the 'Refine your search' expandable section in the Koha OPAC is not clearly announced by screen readers.
The reason for this is that the expandable section toggle button is instead identified and announced as a link.
This results in screen reader users incorrectly expecting to be redirected to another page, and not being informed that there is a expandable section.

For elements with a class of menu-collapse-toggle, add an aria-expanded attribute which defaults to false, and is toggled to true upon that specific section being expanded.
If the screen width is 992px or higher, then remove the aria-expanded attribute on load as it is irrelevant, and potentially misleading.

To test:

1) Apply the patch.

on a small screen:

2) Run a library catalogue search in the Koha OPAC.
3) Right click on the page to inspect it.
4) Inspect the 'Refine your search' element.
5) Notice that it now has a aria-expanded attribute which is set to false.
6) Open the expandable 'Refine your search' section.
7) Notice that the aria-expanded attribute on the 'Refinine your search' element is now set to true.
8) Navigate to Home > Most popular titles
9) Repeat steps 3-7
10) Navigate to Home > Details for > Full subscription history
11) Repeat steps 3-7

then, on a bigger screen (992px and above)

12) Run a library catalogue search in the Koha OPAC.
13) Right click on the page to inspect it.
14) Inspect the 'Refine your search' element.
15) Notice that there is no 'aria-expanded' attribute, as in this case the section isn't expandable.
16) Resize your viewport below 992px, and notice that 'aria-expanded' reappears and is set to false.
17) Resize your viewport while remaining below the 992px limit, and notice that 'aria-expanded' remains set to false.
18) Open 'Refine your search', notice that 'aria-expanded' is set to true.
19) Resize your viewport while remaining below the 992px limit, and notice that 'aria-expanded' remains set to true.

Note: now updated to handle screen resizes
Comment 14 Chloé Zermatten 2025-05-22 15:03:13 UTC
(In reply to Julian Maurice from comment #12)
> Comment on attachment 182565 [details] [review] [review]
> Bug 39489: 'Refine your search' aria-expanded attribute
> 
> Review of attachment 182565 [details] [review] [review]:
> -----------------------------------------------------------------
> 
> ::: koha-tmpl/opac-tmpl/bootstrap/js/results-list.js
> @@ +240,4 @@
> >          KOHA.Tags.add_tag_button(thisid, tag);
> >          return false;
> >      });
> > +    $(window).on("resize load", function () {
> 
> This is not needed: there is already a function (facetMenu) called on load
> and whenever the screen width goes under or above the break point of 992px
> (and only in that case, not on every resize)
> You should put the aria-expanded logic in facetMenu
> 
> @@ +244,5 @@
> > +        $(".menu-collapse-toggle").each(function () {
> > +            const beforeContent = window.getComputedStyle(
> > +                this,
> > +                "::before"
> > +            ).content;
> 
> You should avoid relying on style to define behavior, because whenever the
> style change it might break functionality.

Thank you for the pointers - patch amended accordingly!
Comment 15 David Nind 2025-05-23 22:07:56 UTC
Changed to signed off, ready for QA again.

(I don't think it needs to be tested again, as this is just incorporating QA feedback.)
Comment 16 Marcel de Rooy 2025-06-06 07:29:45 UTC
Please add a signoff line.
Comment 17 David Nind 2025-06-06 08:28:18 UTC
Created attachment 183057 [details] [review]
Bug 39489: 'Refine your search' aria-expanded attribute

On smaller screens (phones, tablets), the 'Refine your search' expandable section in the Koha OPAC is not clearly announced by screen readers.
The reason for this is that the expandable section toggle button is instead identified and announced as a link.
This results in screen reader users incorrectly expecting to be redirected to another page, and not being informed that there is a expandable section.

For elements with a class of menu-collapse-toggle, add an aria-expanded attribute which defaults to false, and is toggled to true upon that specific section being expanded.
If the screen width is 992px or higher, then remove the aria-expanded attribute on load as it is irrelevant, and potentially misleading.

To test:

1) Apply the patch.

on a small screen:

2) Run a library catalogue search in the Koha OPAC.
3) Right click on the page to inspect it.
4) Inspect the 'Refine your search' element.
5) Notice that it now has a aria-expanded attribute which is set to false.
6) Open the expandable 'Refine your search' section.
7) Notice that the aria-expanded attribute on the 'Refinine your search' element is now set to true.
8) Navigate to Home > Most popular titles
9) Repeat steps 3-7
10) Navigate to Home > Details for > Full subscription history
11) Repeat steps 3-7

then, on a bigger screen (992px and above)

12) Run a library catalogue search in the Koha OPAC.
13) Right click on the page to inspect it.
14) Inspect the 'Refine your search' element.
15) Notice that there is no 'aria-expanded' attribute, as in this case the section isn't expandable.
16) Resize your viewport below 992px, and notice that 'aria-expanded' reappears and is set to false.
17) Resize your viewport while remaining below the 992px limit, and notice that 'aria-expanded' remains set to false.
18) Open 'Refine your search', notice that 'aria-expanded' is set to true.
19) Resize your viewport while remaining below the 992px limit, and notice that 'aria-expanded' remains set to true.

Note: now updated to handle screen resizes
Signed-off-by: David Nind <david@davidnind.com>