-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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(progress-bar): fix label accessibility violation #9479
fix(progress-bar): fix label accessibility violation #9479
Conversation
✔️ Deploy Preview for carbon-react-next ready! 🔨 Explore the source changes: ad3ac85 🔍 Inspect the deploy log: https://app.netlify.com/sites/carbon-react-next/deploys/612d195cdd46d60007a186f4 😎 Browse the preview: https://deploy-preview-9479--carbon-react-next.netlify.app |
✔️ Deploy Preview for carbon-elements ready! 🔨 Explore the source changes: ad3ac85 🔍 Inspect the deploy log: https://app.netlify.com/sites/carbon-elements/deploys/612d195cac0a2d00084b1976 😎 Browse the preview: https://deploy-preview-9479--carbon-elements.netlify.app |
✔️ Deploy Preview for carbon-components-react ready! 🔨 Explore the source changes: ad3ac85 🔍 Inspect the deploy log: https://app.netlify.com/sites/carbon-components-react/deploys/612d195cf3cb6c000815efed 😎 Browse the preview: https://deploy-preview-9479--carbon-components-react.netlify.app |
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 don't think using a non-semantic element as a label here is the way we want to go. We should be able to either a) use a for
attribute on the label to associate it with the progressbar or b) explicitly label the progress bar by wrapping it in the <Label>
element.
That said I think we potentially have an Accessibility Checker bug on our hands here. In my testing I wrapped the progressbar in the label element like this
<label>A Progress Bar
<div role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100">20
</div>
</label>
(you can check it out yourself in this Codepen)
Which, barring some little known quirk with role="progressbar"
should be clearing this error. In fact if we look at the Accessibility Tree we see the progressbar labelled correctly
@tombrunet does this track with you?
@dakahn Strictly speaking, wouldn't nesting a |
@dakahn |
@tombrunet Thanks for clarifying that makes sense -- don't know why I was mentally thinking of the progressbar as an input @janhassel you're totally right! Ignore my previous review 👍🏾 |
Fixes an accessiblity violation reported by the IBM Equal Access Accessibility Checker: A progress bar requires a label. The current implementation used a
<label>
element which is unsupported in combination with the target element (progress bar), because it's a<div>
element. Therefore, the implemenation needs to change to usearia-labelledby
instead.Changelog
Changed
<span>
instead<label>
for labelTesting / Reviewing