Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Fix navbar keyboard accessibility #138

Merged
merged 6 commits into from
Aug 23, 2021
Merged

Fix navbar keyboard accessibility #138

merged 6 commits into from
Aug 23, 2021

Conversation

sarayourfriend
Copy link
Contributor

@sarayourfriend sarayourfriend commented Aug 19, 2021

Fixes

Fixes #116 by @sarayourfriend

Description

Adds a Dropdown component based on Vuetensils' Dropdown to make the navbar keyboard accessible.

Technical details

Heavily modifies the Vuetensils' Dropdown to accomodate a couple of things:

  1. Make the keyboard navigation behave the same as WordPress.org's navbar (i.e., no arrow key navigation, just tabbing through each item in order)
  2. Adds focus management to each child by making an onFocus prop available through the default slot. This onFocus prop should be used in the @focus for each dropdown item. This makes it possible to tab "backwards" from a subsequent navbar item. For example, in the real example of the Openverse dropdown if you Shift + Tab from the Web Extension navbar item, you should focus into the last item of the Resources dropdown, not the Resources dropdown itself.
  3. Makes the dropdown container always rendered into the DOM by using the visually hidden styles, lifted from @wordpress/components. This makes the dropdown items always appear in the DOM, making them keyboard focusable while hiding them from sighted users.
  4. Use Bulma classes to fit the existing implementation. This is a drop-in replacement for the existing implementation, style wise, but adds keyboard accessibility (there should be no visual differences between this and the existing implementation).

Tests

If you're on macOS, ensure that you've enabled keyboard navigation in the accessibility options following the instructions here: https://www.a11yproject.com/posts/2017-12-29-macos-browser-keyboard-navigation/

After restarting your browser, you should be able to tab through the navbar items including the dropdown items. Compare this to the live site and you'll see that it was not previously possible.

There are also unit tests to ensure that the focus management works (by teseting the presence of the visible class on the dropdown wrapper).

Checklist

  • My pull request has a descriptive title (not a vague title like Update index.md).
  • My pull request targets the default branch of the repository (main or master).
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added or updated tests for the changes I made (if applicable).
  • [N/A] I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible errors.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@sarayourfriend sarayourfriend requested a review from a team as a code owner August 19, 2021 19:16
Copy link
Contributor

@obulat obulat left a comment

Choose a reason for hiding this comment

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

This is fantastic, Sara. I have left some tiny comments and questions inline. So great to improve a11y on such a vital part of the site!

src/components/Dropdown.vue Outdated Show resolved Hide resolved
src/components/Dropdown.vue Show resolved Hide resolved
src/components/Dropdown.vue Outdated Show resolved Hide resolved
Copy link
Member

@zackkrida zackkrida left a comment

Choose a reason for hiding this comment

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

LGTM! I appreciate the jest --watch script as well.

@sarayourfriend sarayourfriend merged commit 6b902a5 into main Aug 23, 2021
@sarayourfriend sarayourfriend deleted the fix/navbar-a11y branch August 23, 2021 21:05
@zackkrida zackkrida added the ✨ goal: improvement Improvement to an existing user-facing feature label Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
✨ goal: improvement Improvement to an existing user-facing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Impossible to focus nav bar items using keyboard navigation
3 participants