-
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
feat(ListBox): fix labels of trigger buttons #4820
feat(ListBox): fix labels of trigger buttons #4820
Conversation
This change fixes an DAP error in `<ListBox.Field>` that happens because its `aria-label` not matching its text content. DAP takes `aria-labelledby` as a preferred label content (over text content or `aria-label`), and thus this change add `aria-labelledby` to `<ListBox.Field>`. The original `aria-label` content, which is for lettting user know that the UI can open/close menu, is replaced with a browser's native approach to tell assistive technology that the button is a pop-up button and let screen reader announce as such. This change also changes `<label>` to `<span>` for dropdown and non-filterable multi select given there is no form control (`<input>`) associated with it. Fixes carbon-design-system#4531.
Deploy preview for the-carbon-components ready! Built with commit 4894b65 https://deploy-preview-4820--the-carbon-components.netlify.com |
Deploy preview for carbon-components-react ready! Built with commit 4894b65 https://deploy-preview-4820--carbon-components-react.netlify.com |
Deploy preview for carbon-elements ready! Built with commit 4894b65 |
One thing, do we even need the |
This PR removes |
For sure! Sorry if I wasn't clear. I was just thinking through the DAP violation and it seemed like only removing the What is the expected behavior for VO if the button/field is associated with the label? Specifically, how are we thinking the value would be announced? |
If we just remove |
This is why I said this above:
As a result, the idea was that this would not need to be communicated through |
Seems that you have a specific change you have in your mind, or specific lines in this PR that you think should be removed. Do you want to put the code snippet if it's the former? Do you want to put some links to the specific lines of code if it's the latter? Thanks! |
If I understand correctly, the diff would be:
Could easily be wrong though, I believe the structure we have in general is inverted (e.g. trigger is a descendant of listbox, two nodes with Reference:
cc @dakahn just to confirm, don't want to steer anyone in the wrong direction here 👍 |
Did you mean a change to |
Yup! |
Above suggested changes are fine with me, updated. |
Hey @asudoh! For the MultiSelect component, it seems like this PR gets rid of the "Accessible name does not match visible text" DAP violation but then creates a "An interactive/widget must have an accessible name" violation. Not sure if we want/need to address this is in this PR but figured i'd point it out! |
@abbeyhrt Thank you for testing - Not sure if it's a false positive or not, but fixed anyway. |
@abbeyhrt do you have a chance to re-review?? 👀 |
const title = titleText ? ( | ||
<label htmlFor={id} className={titleClasses}> | ||
<span id={id} className={titleClasses}> |
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.
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.
Great catch @abbeyhrt! Was an error in rebasing. Fixed.
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.
Looks great! 🎉
This change fixes an DAP error in
<ListBox.Field>
that happens because itsaria-label
not matching its text content. DAP takesaria-labelledby
as a preferred label content (over text content oraria-label
), and thus this change addaria-labelledby
to<ListBox.Field>
.The original
aria-label
content, which is for letting user know that the UI can open/close menu, is replaced with a browser's native approach to tell assistive technology that the button is a pop-up button and let screen reader announce as such.This change also changes
<label>
to<span>
for dropdown and non-filterable multi select given there is no form control (<input>
) associated with it.Fixes #4531.
Changelog
New
<ListBox.Field>
to list box label.Changed
<label>
with<span>
for the labels of dropdown and (non-filterable) multi select.Removed
aria-label
from the<div role="button">
in<ListBox.Field>
.Testing / Reviewing
Testing should make sure combo box, drop down, multi select, filterable multi select are not broken.
For reviewers - It's easier to review with whitespace change ignored, it can be done by clicking on the gear icon in Files changed tab and check off "Hide whitespace changes".