-
-
Notifications
You must be signed in to change notification settings - Fork 9k
fix(theme-classic): make nav dropdowns focusable #6003
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
Conversation
Hi @robinmetral! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
✔️ [V2] 🔨 Explore the source changes: d427eb6 🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-2/deploys/61b0ecdfde88fc000795aab0 😎 Browse the preview: https://deploy-preview-6003--docusaurus-2.netlify.app |
⚡️ Lighthouse report for the changes in this PR:
Lighthouse ran on https://deploy-preview-6003--docusaurus-2.netlify.app/ |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
Thanks for the fix! It makes sense to me. Actually, we'd like to do it all since you brought it up. Do you have the bandwidth to kindly address the a11y issue you mentioned, or would you like me to take care of the rest? |
packages/docusaurus-theme-classic/src/theme/NavbarItem/DropdownNavbarItem.tsx
Outdated
Show resolved
Hide resolved
Unfortunately not, this was more of a Boy Scout Rule-style pull request. I'd be happy to help review and test though if you need some a11y support 🙂 Update
I think I wrong here: actual menus should have this behavior (ex. it opens when you click it, or press So if that's right (☝️), the issue with focusing the top-level menu item is the only issue. I can address your comment on this branch and it should be ready to go @Josh-Cena 🙂 |
Thanks, indeed we don't need to navigate with arrow keys / esc; however, focusing to a dropdown still doesn't expand its children and make them accessible with tabs. I do think that's worth fixing. Edit. Actually, forgive me, they are accessible with Enter🤦♂️ Not sure if it's the most straightforward UX though |
You're right, from what I've seen a best practice here is to make sure that the subnav opens on focus and allows tabbing through |
We should probably do it since this is a subnav and not a menu, but the downside is that we'll "force" keyboard users to e.g. tab through all versions of the docs in a doc versions dropdown. The alternative is to make this a menu, but the top-level item could not be a link anymore (it should just be a toggle in that case) |
Well—I see the point. In that case using a separate key to expand the dropdown makes sense. I don't think there's any convention about visual cues that an element is Enter'able, esc'able, or allowing other interactions |
Exactly, the main issue is what you're mentioning: there's no pattern to announce that there are subnav items, so screenreader users wouldn't find them (sighted keyboard users might, via the chevron icon 🔽). I can think of several ways to address it:
TBH I'd recommend going for the first option here, since there would be no change for mouse users and the PR is already an improvement for keyboard users. So tl;dr:
Thoughts? |
It's quite late here and I'm going 🤯 So I'll be revisiting this tomorrow. Thanks again for working on this! |
Haha sorry for the late-night brain workout—thanks a lot for your quick response here and let me know if you need further inputs from me tomorrow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey
Agree that we may not do the right thing regarding a11y here
But this PR makes it consistent with other existing dropdowns, so that seems good enough to merge.
We can improve the a11y on all dropdowns at once in another PR
Thanks
This PR adds
href="#"
to the classic theme'sDropdownNavbarItem
in order to make it focusable.Here's the issue in action on pnpm.io (notice how tabbing skips the "Support us" item):
Screen.Recording.2021-11-24.at.12.07.55.mov
This solution is still not ideal in terms of a11y since dropdowns should close on
ESC
and should be navigable with arrow keys, but it makes them usable 🙂This was already implemented in the locale dropdown, I simply moved the logic over to the
DropdownNavbarItem
instead.