-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
ProgressBar: Add default tabIndex
to make focusable
#53383
Conversation
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.
I believe what we're looking for (at least in the loading screen use case in #53032) is to associate the progress
with the loading region
.
I don't think <progress>
elements are intended to ever be focusable, since they're not interactive.
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.
Sorry for causing a waste of time here. Turns out, the component has correct markup after the MDN example and no further work should be done to it.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/progress
I'll head back over to the other PR to continue discussion.
Thanks for the info, @alexstine and @mirka 🙌 I'm happy to follow up on improving the component if anything occurs in the meantime. |
What?
This PR updates the
ProgressBar
component to make it focusable.cc @alexstine @andrewhayward for accessibility feedback.
Why?
While working on #53032 I noticed that the underlying
progress
element is not focusable and that makes it inaccessible. That meant we have to make it focusable so users with screen readers will be able to focus it and get it announced properly.How?
This PR adds a default
tabIndex
of0
to the underlyingprogress
HTML element to make it focusable. We still allow the component user to override the value if they wish.I'm also adding a unit test to verify the focusing works as expected. You can try removing the
tabIndex
and you should see the new test failing.Testing Instructions
npm run storybook:dev
, load http://localhost:50240/?path=/story/components-experimental-progressbar--defaultTesting Instructions for Keyboard
Whether in the site editor or in Storybook, the element should be the sole focusable element in the canvas, so tabbing once should be enough.
Screenshots or screencast
None.