-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix: Combobox VoiceOver announcement not respecting aria-label
of ListBoxItem
#8908
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
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.
thanks for catching that and starting a PR!
node.rendered = rendered; | ||
node.render = render; | ||
node.value = value; | ||
if (obj['aria-label']) { |
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.
generally we try to add as little as possible to these nodes, so I think we'd prefer the other option and read from focusedItem.props['aria-label']
and section.props['aria-label']
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.
Alright. Just to clarify, the attribute aria-label
already on the node, it is just not initialized:
react-spectrum/packages/@react-aria/collections/src/BaseCollection.ts
Lines 23 to 42 in 307b71c
export class CollectionNode<T> implements Node<T> { | |
static readonly type: string; | |
readonly type: string; | |
readonly key: Key; | |
readonly value: T | null = null; | |
readonly level: number = 0; | |
readonly hasChildNodes: boolean = false; | |
readonly rendered: ReactNode = null; | |
readonly textValue: string = ''; | |
readonly 'aria-label'?: string = undefined; | |
readonly index: number = 0; | |
readonly parentKey: Key | null = null; | |
readonly prevKey: Key | null = null; | |
readonly nextKey: Key | null = null; | |
readonly firstChildKey: Key | null = null; | |
readonly lastChildKey: Key | null = null; | |
readonly props: any = {}; | |
readonly render?: (node: Node<any>) => ReactElement; | |
readonly colSpan: number | null = null; | |
readonly colIndex: number | null = null; |
There seems to be a good part of the codebase that is reading aria-label
directly from the node, see ListBoxOption.tsx
, MenuSection.tsx
...
Would you still prefer the other way (read from focusedItem.props['aria-label']
and section.props['aria-label']
) ? In that case I'd suggest to remove the aria-label
attribute from the node class altogether and migrate all usages to node.props?.['aria-label']
.
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.
Just a small note, I removed the if condition i originally had here to ensure that the sync performed by setProps
also works if the react-aria prop changes from a value to undefined
.
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 seems to be a good part of the codebase that is reading aria-label directly from the node
O, thank you, I'd missed that. Will follow it up with the team and see why we are doing that.
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.
just to update, this was mainly a backcompat addition between the new collections implementation and the old collections implementation which originally added aria-label
to the node directly. We'll want to keep aria-label
on the node class but reading it from props is fine
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.
thanks for the update and the additional context 👍 appreciate it.
note, you'll need to sign the CLA https://react-spectrum.adobe.com/contribute.html#contributor-license-agreement |
I've signed the CLA 👍 |
5a62518
to
a11dcf8
Compare
@snowystinger any updates, do you need anything from me to continue here? happy to hear from you I rebased on latest |
This can be used to check whether the screen-reader announcement for option selections reads the correct label for each option, especially on mac, where there is a special codepath for this.
This commit ensures the aria-label prop from the ListItem is read into the corresponding attribute ElementNode
a11dcf8
to
7e694f6
Compare
Not yet, we're in the middle of release testing, so apologies if we move a little slowly. |
aria-label
of ListBoxItem
aria-label
of ListBoxItem
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.
Tested locally in VO, verified the announcement came though properly, thanks for fixing this!
Thanks for getting this merged and taking the time to make an informed decision about that. |
…ListBoxItem` (#8908) * add ComboBox Story for ListBoxItem with aria-label This can be used to check whether the screen-reader announcement for option selections reads the correct label for each option, especially on mac, where there is a special codepath for this. * fix `CollectionBuilder` to handle `aria-label` correctly This commit ensures the aria-label prop from the ListItem is read into the corresponding attribute ElementNode * only add key if it exists --------- Co-authored-by: Robert Snow <rsnow@adobe.com> Co-authored-by: Robert Snow <snowystinger@gmail.com>
sIssue describing the problem and the root cause: #8907
This PR fixes the problem I described in detail in the issue linked above. Please note that there is another strategy to fix this, which I outlined in the issue as well.
✅ Pull Request Checklist:
📝 Test Instructions:
Refer to the linked issue, which includes detailed reproduction instructions.
Short version:
Combo Box List Box Item With Aria Label
and activate VoiceOver.aria-label
instead of the one specified viatextValue
.