-
Notifications
You must be signed in to change notification settings - Fork 1.3k
#3578 Add the ability to add a data attribute to <HiddenSelect /> to handle false a11y positives #4759
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
#3578 Add the ability to add a data attribute to <HiddenSelect /> to handle false a11y positives #4759
Conversation
This allows to use the data attribute as a reference for other tools to ignore a11y issues.
This solves adobe#3578 Some tools such as AXE or pa11y might give false positive on hidden select. This add a new prop to expose a data-attribute (dataset) that can be used to ignore these false positives.
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 contribution!!
There were a few lint issues that you can see when you run yarn lint
. Fixing those should fix the build.
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.
Also, I think we can just always add the new data attribute, no prop needed to enable.
There is no harm in making this available, as discussed in the PR review.
@reidbarber I've made the I've also merged in the latest master, but maybe you prefer it rebased? Linting issues should be also resolved. (We'll see once the CI has finished!) |
This fixes an issue in the docs where the component was being parsed when it shouldn't have been parsed.
GET_BUILD |
Build successful! 🎉 |
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! Just a small tweak to the docs to reflect the updates and I'm good to approve.
@@ -87,7 +87,8 @@ export function useHiddenSelect<T>(props: AriaHiddenSelectProps, state: SelectSt | |||
name, | |||
size: state.collection.size, | |||
value: state.selectedKey ?? '', | |||
onChange: (e: React.ChangeEvent<HTMLSelectElement>) => state.setSelectedKey(e.target.value) | |||
onChange: (e: React.ChangeEvent<HTMLSelectElement>) => state.setSelectedKey(e.target.value), | |||
['data-rsp-a11y-ignore']: true |
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.
Think we can get rid of this one too. I figure people can blanket filter out the container div for aXe and pa11y via data-rsp-a11y-ignore
(its the one triggering the "ARIA hidden element must not be focusable or contain focusable elements" false positive) and thus we don't need the attribute on the select props. We could even move this line onto the containerProps
so people using the hook instead of HiddenSelect benefit too.
Did you find that you needed the data attribute on the select element?
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 contribution! I went in and updated it so the data attribute is just on the container props and verified that we could actually use the attribute to suppress the false positive in our own storybook, hope you don't mind. Apologies about highjacking the PR, we wanted to try and get it merged for our testing session on Monday.
Lemme know if you had any thoughts about my comment here, happy to update in a followup if it turns out we need the attribute on more that just the container
GET_BUILD |
### False positive on `<HiddenSelect />` in accessibility tools | ||
|
||
When using <<TypeLink links={docs.links} type={docs.exports.HiddenSelect} />> some accessibility tools such as AXE or pa11y might give a false positive. | ||
The data attribute `data-rsp-a11y-ignore` is included on the hidden select element and can be used to ignore the false positives in these tools. |
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.
For the team, open to opinions on where this information should go. Perhaps we should add a new section in this docs page for accessibility gotchas (or simply accessiblity?)
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'm fine with where it is, but not against a dedicated accessibility section either.
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.
+1 to Reid's comment. I think this is fine where it is but a new section for accessibility gotchas would be nice
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, I'll approve this PR and make a followup one moving it to a separate accessibility section.
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.
It definitely shouldn't be under "Internationalization" IMO, seems unrelated to that. Also we will need to cover this on all of the other select pages: RAC Select and RSP Picker. If it is going to be a general way for us to indicate false positives, we may also want to document it on a more general page such as the "Accessibility" one.
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.
good point about covering this on the other Select pages. By the "Accessibility" page I assume you are referencing this? If so, I think that is a good idea.
@abitbetterthanyesterday IMO this is creeping in scope a bit, would you like to take this on? I'd be perfectly happy making followup PR for this as well instead.
Build successful! 🎉 |
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.
LGTM, thanks once again for the contribution!
@@ -71,7 +71,8 @@ export function useHiddenSelect<T>(props: AriaHiddenSelectProps, state: SelectSt | |||
return { | |||
containerProps: { | |||
...visuallyHiddenProps, | |||
'aria-hidden': true | |||
'aria-hidden': true, | |||
['data-rsp-a11y-ignore']: true |
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.
This probably should not have rsp
in the name because it's not spectrum specific, this will also affect React Aria. Maybe just data-a11y-ignore
?
### False positive on `<HiddenSelect />` in accessibility tools | ||
|
||
When using <<TypeLink links={docs.links} type={docs.exports.HiddenSelect} />> some accessibility tools such as AXE or pa11y might give a false positive. | ||
The data attribute `data-rsp-a11y-ignore` is included on the hidden select element and can be used to ignore the false positives in these tools. |
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.
It definitely shouldn't be under "Internationalization" IMO, seems unrelated to that. Also we will need to cover this on all of the other select pages: RAC Select and RSP Picker. If it is going to be a general way for us to indicate false positives, we may also want to document it on a more general page such as the "Accessibility" one.
Hm, feel free to take it on. I have a bit on my plate right now so you
might be more available.
Thanks for all your help.
…On Thu, Jul 20, 2023, 9:46 AM Daniel Lu ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In ***@***.***/select/docs/useSelect.mdx
<#4759 (comment)>
:
> +### False positive on `<HiddenSelect />` in accessibility tools
+
+When using <<TypeLink links={docs.links} type={docs.exports.HiddenSelect} />> some accessibility tools such as AXE or pa11y might give a false positive.
+The data attribute `data-rsp-a11y-ignore` is included on the hidden select element and can be used to ignore the false positives in these tools.
good point about covering this on the other Select pages. By the
"Accessibility" page I assume you are referencing this
<https://react-spectrum.adobe.com/react-aria/accessibility.html#accessibility>?
If so, I think that is a good idea.
@abitbetterthanyesterday <https://github.com/abitbetterthanyesterday> IMO
this is creeping in scope a bit, would you like to take this on? I'd be
perfectly happy making followup PR for this as well instead.
—
Reply to this email directly, view it on GitHub
<#4759 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEHYZ4XIXBDCMG3WUFCX443XRBWU7ANCNFSM6AAAAAA2HO4A7M>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
d9ed730
Is there anything left I can do to get this in? |
I'm hoping to get this reviewed by the team and merged in as is by early next week, then will open a followup PR shortly after addressing the rest of the comments. |
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.
LGTM
### False positive on `<HiddenSelect />` in accessibility tools | ||
|
||
When using <<TypeLink links={docs.links} type={docs.exports.HiddenSelect} />> some accessibility tools such as AXE or pa11y might give a false positive. | ||
The data attribute `data-rsp-a11y-ignore` is included on the hidden select element and can be used to ignore the false positives in these tools. |
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.
The data attribute `data-rsp-a11y-ignore` is included on the hidden select element and can be used to ignore the false positives in these tools. | |
The data attribute `data-a11y-ignore` is included on the hidden select element and can be used to ignore the false positives in these tools. |
It got renamed right?
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'll update in a followup
GET_BUILD |
Build successful! 🎉 |
## API Changes
unknown top level export { type: 'identifier', name: 'Column' } |
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 contribution!
Closes #3578
This PR simply add the ability to expose a data-attribute on the
<HiddenElement />
ofuseSelect
.This is useful when using a tool such as AXE or pa11y giving you false positive - the data attribute is a good way to force the tool to ignore the false positive.
✅ Pull Request Checklist:
📝 Test Instructions:
useSelect
documentation example), ensuring that theprops
contains{hasA11yIgnoreDataAttr: true}
data-rsp-a11y-ignore
.yarn jest
)🧢 Your Project:
N/A