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

refactor: improve a11y of dropdown menu #6971

Merged
merged 8 commits into from
Mar 25, 2022
Merged

Conversation

lex111
Copy link
Contributor

@lex111 lex111 commented Mar 23, 2022

Motivation

Better identification of dropdown menus for screen readers and slightly improvement of UX when navigating from the keyboard on navbar menu items from dropdown items.

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

ezgif com-gif-maker

Related PRs

@lex111 lex111 added the pr: polish This PR adds a very minor behavior improvement that users will enjoy. label Mar 23, 2022
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Mar 23, 2022
@netlify
Copy link

netlify bot commented Mar 23, 2022

[V2]

Name Link
🔨 Latest commit f5a6366
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/623da8433f11e80008f4cdc3
😎 Deploy Preview https://deploy-preview-6971--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions
Copy link

github-actions bot commented Mar 23, 2022

⚡️ Lighthouse report for the changes in this PR:

Category Score
🟠 Performance 52
🟢 Accessibility 100
🟢 Best practices 92
🟢 SEO 100
🟢 PWA 90

Lighthouse ran on https://deploy-preview-6971--docusaurus-2.netlify.app/

@github-actions
Copy link

github-actions bot commented Mar 23, 2022

Size Change: +33 B (0%)

Total Size: 805 kB

Filename Size Change
website/build/assets/css/styles.********.css 105 kB +475 B (0%)
website/build/assets/js/main.********.js 612 kB -49 B (0%)
website/build/index.html 38.4 kB -393 B (-1%)
ℹ️ View Unchanged
Filename Size
website/.docusaurus/globalData.json 49.9 kB

compressed-size-action

@slorber
Copy link
Collaborator

slorber commented Mar 24, 2022

🤷‍♂️ I don't really notice a difference compared to before

feel free to self merge if you think it improves, I'm not a11y skilled enough to be sure

@lex111
Copy link
Contributor Author

lex111 commented Mar 24, 2022

The aria- attributes are for screen readers (it now reads out dropdown as a menu), and the changes in onKeyDown I demonstrated in the GIF above.

@Josh-Cena
Copy link
Collaborator

Josh-Cena commented Mar 24, 2022

I vaguely remember that dropdowns were purposefully made not able to be tabbed through. Users can quickly tab through the navbar without being trapped in any of the long dropdowns. They can still use Enter to open the dropdown first, and then tab through it. I think we just need to make that more explicit through some aria label.

@slorber
Copy link
Collaborator

slorber commented Mar 25, 2022

I vaguely remember that dropdowns were purposefully made not able to be tabbed through.

On the preview, I don't enter the dropdown with tab

I demonstrated in the GIF above.

Can't be sure which keys you press on that Gif 🤷‍♂️ when only using tabs on the preview, I don't see the behavior in this Gif

@lex111
Copy link
Contributor Author

lex111 commented Mar 25, 2022

It's simple: Tab to navigate through any navbar items, Enter to open and close a dropdown menu.

@Josh-Cena
Copy link
Collaborator

Ah yeah, misunderstood what this PR does. It would focus the a element for dropdowns instead of the div. There does seem to be a difference with screen readers, but can't tell which is better.

@lex111
Copy link
Contributor Author

lex111 commented Mar 25, 2022

Trouble is now when navigating from last item in a dropdown menu, the focus goes to a next navbar item, but if it is a another dropdown, the focus will not be visible.

@Josh-Cena
Copy link
Collaborator

Ah, I see. Makes sense

@slorber
Copy link
Collaborator

slorber commented Mar 25, 2022

LGTM 👍

@slorber slorber merged commit d879cdc into main Mar 25, 2022
@slorber slorber deleted the lex111/dropdown-menu-a11y branch March 25, 2022 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: polish This PR adds a very minor behavior improvement that users will enjoy.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants