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

ProgressBar: Add default tabIndex to make focusable #53383

Closed
wants to merge 4 commits into from

Conversation

tyxla
Copy link
Member

@tyxla tyxla commented Aug 7, 2023

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 of 0 to the underlying progress 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

Testing 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.

@tyxla tyxla added [Type] Enhancement A suggestion for improvement. [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Package] Components /packages/components Needs Accessibility Feedback Need input from accessibility labels Aug 7, 2023
@tyxla tyxla requested a review from ajitbohra as a code owner August 7, 2023 09:20
@tyxla tyxla self-assigned this Aug 7, 2023
@tyxla tyxla removed the [Type] Enhancement A suggestion for improvement. label Aug 7, 2023
@WordPress WordPress deleted a comment from github-actions bot Aug 7, 2023
@WordPress WordPress deleted a comment from github-actions bot Aug 7, 2023
@WordPress WordPress deleted a comment from github-actions bot Aug 7, 2023
Copy link
Member

@mirka mirka left a 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.

Copy link
Contributor

@alexstine alexstine left a 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.

@alexstine alexstine closed this Aug 10, 2023
@tyxla tyxla deleted the update/progress-bar-add-tabindex branch August 10, 2023 10:16
@tyxla
Copy link
Member Author

tyxla commented Aug 10, 2023

Thanks for the info, @alexstine and @mirka 🙌 I'm happy to follow up on improving the component if anything occurs in the meantime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). Needs Accessibility Feedback Need input from accessibility [Package] Components /packages/components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants