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

fix(a11y): Fix keyboard navigation issues with sidebar #8769

Merged
merged 3 commits into from
Nov 15, 2024

Conversation

thomasheartman
Copy link
Contributor

@thomasheartman thomasheartman commented Nov 15, 2024

This PR fixes a number of keyboard accessibility issues with the feedback sidebar. They are (in no particular order):

  1. The radio inputs don't have a focus style for focus-visible (when keyboard focused).
  2. There's two close buttons there for some reason? One is invisible, but you can tab to it?
  3. The sidebar doesn't trap focus, so you can tab out of the modal and continue tabbing through the main page (with the modal still open)
  4. The sidebar doesn't steal focus. When you open it, your focus remains on the button you used to open it. So if you want to navigate to it, you have to go through the entire page (behind the modal) to get to it.
  5. The sidebar can't be closed by 'escape'.

The fixes are:

  1. Apply the same styles when focus visible as when hover
  2. Wrap the component in the BaseModal component
  3. Wrap the component in the BaseModal component
  4. Wrap the component in the BaseModal component
  5. Wrap the component in the BaseModal component

(see a theme here?)

Additionally, because the base modal has its own open state, I removed the wrapping conditionally render, reducing nesting by one stop. Most of the changes in the file are just whitespace changes.

image

I considered also applying an auto-focus to the first input in the sidebar, but our linter doesn't like it. Additionally MDN lists the following accessibility concerns

Automatically focusing a form control can confuse visually-impaired people using screen-reading technology and people with cognitive impairments. When autofocus is assigned, screen-readers "teleport" their user to the form control without warning them beforehand.

Use careful consideration for accessibility when applying the autofocus attribute. Automatically focusing on a control can cause the page to scroll on load. The focus can also cause dynamic keyboards to display on some touch devices. While a screen reader will announce the label of the form control receiving focus, the screen reader will not announce anything before the label, and the sighted user on a small device will equally miss the context created by the preceding content.

So I'll leave it off.

Copy link

vercel bot commented Nov 15, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
unleash-monorepo-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 15, 2024 9:16am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
unleash-docs ⬜️ Ignored (Inspect) Visit Preview Nov 15, 2024 9:16am

Copy link
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Files

Copy link
Contributor

@sjaanus sjaanus left a comment

Choose a reason for hiding this comment

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

Nice!

@thomasheartman thomasheartman merged commit 0465731 into main Nov 15, 2024
13 checks passed
@thomasheartman thomasheartman deleted the 1-3124/feedback-sidebar-keyboard branch November 15, 2024 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants