Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add skip links and refactor filter sidebar for accessibility #140

Merged
merged 3 commits into from
Mar 26, 2024

Conversation

jazairi
Copy link
Contributor

@jazairi jazairi commented Mar 22, 2024

Why these changes are being introduced:

This application has many focusable elements, and it may be helpful
to users of assistive technology to provide skip links to different
sections.

Relevant ticket(s):

How this addresses that need:

This pulls in the application layout from the theme gem and adds to it the following skip links:

  • All views: nav, search form
  • Results: results list, filter sidebar
  • Record: record metadata

It also makes the filter sidebar more semantically meaningful. As currently written, VoiceOver does not parse the filter menus as disclosure triangles, and thus tabs through each available filter in a menu even while it is collapsed.. The menus are now written as details elements, which VoiceOver interprets correctly.

In the process of refactoring the filter sidebar, I also made a small change to the menu toggler. This had been assigned to an onclick attribute, but it is now more appropriately an event listener, and moved to the same file as the logic for the mobile filter toggler.

Side effects of this change:

The main side effect is the added technical debt of maintaining a separate version of application.html.erb. This shouldn't be especially onerous, as that file is rarely updated. Additional side effects are noted in each commit message.

Developer

Accessibility
  • ANDI or WAVE has been run in accordance to our guide.
  • This PR contains no changes to the view layer.
  • New issues flagged by ANDI or WAVE have been resolved.
  • New issues flagged by ANDI or WAVE have been ticketed (link in the Pull Request details above).
  • No new accessibility issues have been flagged.
New ENV
  • All new ENV is documented in README.
  • All new ENV has been added to Heroku Pipeline, Staging and Prod.
  • ENV has not changed.
Approval beyond code review
  • UXWS/stakeholder approval has been confirmed.
  • UXWS/stakeholder review will be completed retroactively.
  • UXWS/stakeholder review is not needed.
Additional context needed to review

Note that this PR includes three commits: one to pull in the upstream layout, one to add the skip links, and one to refactor the filter sidebar. It will likely be easier to review by looking at each commit individually, from oldest to newest.

To verify the skip links, ensure that tab/screen reader navigation focuses on the following links before any other element, and they link to the correct section:

  • Landing page: main menu (nav), search form (beginning with basic search)
  • Results page: main menu, search form, search results, search filters
  • Record page: main menu, metadata

To verify the filter refactor, ensure that tab/screen reader navigation focuses only on the filter menu label if it is collapsed. If the menu is open, it should focus first on the label, then on each available filter. Additionally, screen readers should read "apply filter" before available filters, and "remove filter" before applied filters.

You should also confirm that filter menus can be opened and closed, and that filters can be applied and removed, in both the mobile and desktop views.

Code Reviewer

Code
  • I have confirmed that the code works as intended.
  • Any CodeClimate issues have been fixed or confirmed as
    added technical debt.
Documentation
  • The commit message is clear and follows our guidelines
    (not just this pull request message).
  • The documentation has been updated or is unnecessary.
  • New dependencies are appropriate or there were no changes.
Testing
  • There are appropriate tests covering any new functionality.
  • No additional test coverage is required.

@mitlib mitlib temporarily deployed to timdex-ui-pi-gdt-161-sk-3a59mi March 22, 2024 20:50 Inactive
@coveralls
Copy link

coveralls commented Mar 22, 2024

Pull Request Test Coverage Report for Build 8441324055

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 98.872%

Totals Coverage Status
Change from base Build 8437037131: 0.0%
Covered Lines: 526
Relevant Lines: 532

💛 - Coveralls

@JPrevost JPrevost self-assigned this Mar 22, 2024
Copy link
Member

@JPrevost JPrevost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll confirm the functionality shortly and work towards approving this.

I do have reservations about this feature and may want to discuss it further (not sure who would need to be involved quite yet) as I'm nervous we may be adding additional skip links when the actual problem is potentially how we present the content to begin with.

@mitlib mitlib temporarily deployed to timdex-ui-pi-gdt-161-sk-nf5cwq March 25, 2024 17:40 Inactive
Copy link
Member

@JPrevost JPrevost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to at minimum address the id vs class for skip links. Either as timdex-ui overrides (with a ticket to move them to the theme/style guide) or directly in the theme/style guide.

We also need to resolve the bug with Safari not tabbing to our skip links. That could handled by adding an override style to timdex-ui and/or opening a ticket to resolve it at the theme gem/style guide level.

I believe you have already confirmed you will add a new feature to the theme gem to support overriding skip links rather than forking the template.

@jazairi jazairi temporarily deployed to timdex-ui-pi-gdt-161-sk-nf5cwq March 26, 2024 17:22 Inactive
@jazairi
Copy link
Contributor Author

jazairi commented Mar 26, 2024

The latest commit updates the theme gem in order to move the changes to a skip links partial (introduced here and released in v1.4). For now, I addressed the Safari bug in TIMDEX UI only, but I opened ENGX-260 to fix it in the style guide.

During our team meeting today, we discussed the possibility of wrapping multiple skip links in another tag, so we can continue to use the #skip selector rather than introducing a new class. I tried a few different iterations of this, and each of them caused the skip links to be invisible. I do think an unordered list would be more semantically meaningful here, but in the spirit of red-green-refactor, I suppose a series of a tags is good enough for now.

@jazairi jazairi requested a review from JPrevost March 26, 2024 17:26
@jazairi
Copy link
Contributor Author

jazairi commented Mar 26, 2024

Before I merge, I will also move the addition of the new partial into its own commit, as is our practice, so it's clearer what the changes are.

Copy link
Member

@JPrevost JPrevost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Safari is still wonky, but I'd be okay with handling that as a separate ticket as it may require us a bit of time to work through the best way to handle it as the behavior is just weird.

@jazairi
Copy link
Contributor Author

jazairi commented Mar 26, 2024

Yeah, the Safari situation is looking increasingly rough. Adding the :focus-visible selector doesn't fix it, so we'll probably need a polyfill. I updated ENGX-260 with the article you found on the subject.

jazairi added 3 commits March 26, 2024 14:30
Why these changes are being introduced:

We are trying out custom skip links for this application, as
it has a relatively complex navigation structure. The theme gem
has been updated to support this, using a new `_skip_links` partial.

Relevant ticket(s):

* [GDT-161](https://mitlibraries.atlassian.net/browse/GDT-161)

How this addresses that need:

This updates the theme gem and adds the new partial as-is. It will
be customized in a subsequent commit.

Side effects of this change:

A small amount of technical debt may be added here, but incorporating
a layout that needs to remain compatible with the upstream theme
gem. However, the partial itself is very simple, so it's unlikely
that any maintenance will be required.
Why these changes are being introduced:

This application has many focusable elements, and it may be helpful
to users navigating with keyboards or screen readers if we provide
links to skip to different sections.

Relevant ticket(s):

* [GDT-161](https://mitlibraries.atlassian.net/browse/GDT-161)

How this addresses that need:

This adds the following skip links to the `_skip_links` partial:
* All views: nav, search form
* Results: results list, filter sidebar
* Record: record metadata

It also adds `.skip-link` rules to our SCSS, copied from the
`#skip` rules in the style guide with two changes:
* The `width: 0` rule has been removed in a step towards partial
Safari support, as Safari will not focus on elements with this
rule.
* The color of skip links on focus is now white, as the current
blue-on-black is a contrast error.

Safari has a significant focus bug that Apple seems unlikely to fix.
[This article](https://itnext.io/fixing-focus-for-safari-b5916fef1064)
details the problem and provides a polyfill that solves it. As this
bug likely affects all of our applications, we should incorporate
that polyfill in the style guide. I've opened [ENGX-260](https://mitlibraries.atlassian.net/browse/ENGX-260)
to do so.

Side effects of this change:

* Some IDs have been added to top-level elements to make them
selectable.
* While working on this, I realized that VoiceOver doesn't recognize
the filter labels as disclosure triangles, so even when they are
closed, it tabs through every available filter. I've fixed this
in a subsequent commit.
* There is an open question as to whether this is too many skip
links. [WebAIM's guidance on skip links](https://webaim.org/techniques/skipnav/#multiple)
suggests that one is optimal, but more than one may be necessary
in some cases. Whether our use case necessitates them is somewhat
unclear, as are the best practices for how many links to provide
if you are providing multiple. I plan to discuss this further with
Darcy in UX review. If we can't come to a decision, it would be a
good question for DAS.
Why these changes are being introduced:

VoiceOver (and possibly other screen readers) do not interpret
the current sidebar drawers as disclosure triangles. As such,
one must tab through every available filter, even if that
filter category is collapsed.

Relevant ticket(s):

* https://mitlibraries.atlassian.net/browse/GDT-161

How this addresses that need:

This refactors filter categories as `details` tags, so screen readers
will recognize them as expandable elements.

Side effects of this change:

* Some tests have been updated a result of changes to class names.
* We had previously been opening/closing categories with an `onclick`,
was a quick-and-dirty way to get things working but not very good
practice. I took this opportunity to change that too an event
listener and moved it to the `filters.js` file that we added for
the mobile filter toggle button.
* I've removed the transition rules for the filters, since `details`
does not support them natively.
@jazairi jazairi force-pushed the gdt-161-skip-links branch from 7e245e0 to 5c503b3 Compare March 26, 2024 18:47
@jazairi jazairi temporarily deployed to timdex-ui-pi-gdt-161-sk-nf5cwq March 26, 2024 18:48 Inactive
@jazairi jazairi merged commit f25953a into main Mar 26, 2024
5 checks passed
@jazairi jazairi deleted the gdt-161-skip-links branch March 26, 2024 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants