Closed mpalmer685 closed 2 months ago
See https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-hidden
aria-hidden="true" should not be used on elements that can receive focus. Additionally, since this attribute is inherited by an element's children, it should not be added onto the parent or ancestor of a focusable element.
Can you tell us more about your usecase? @rostero1 is correct, in general it shouldn't be used on a button. Though I'd expand on it and say most of the time, even if it can't receive focus, it still shouldn't be hidden. As an example, look at our Combobox and NumberField, their in-field buttons are not included in the tab focus order, but they are not hidden so that Assitive Technology users can still interact with them.
If you can show us an example of what you're trying to accomplish, we may be able to provide some recommendations that hopefully don't involve aria-hidden.
Assuming there is valid use case to remove the button from the accessibility tree but not from the DOM - the inert
attribute might be the right choice?
Usually I find myself wanting aria-hidden in situations where something is behind a modal overlay or similarly intentionally not available.
You can always wrap the component in an inert element. You should be able to do the same with aria-hidden as well.
Our modals will take care of aria-hiding everything behind them for you without the need to pass props around everywhere.
I'm going to close this for now until a use case comes up.
Provide a general summary of the issue here
Passing the
aria-hidden
prop to the Button component does not work as expected.๐ค Expected Behavior?
Given
<Button aria-hidden={true}>Do the thing</Button>
, the HTML<button>
element should havearia-hidden="true"
๐ฏ Current Behavior
The
aria-hidden
attribute does not get applied.๐ Possible Solution
No response
๐ฆ Context
No response
๐ฅ๏ธ Steps to Reproduce
CodeSandbox
Version
react-aria-components@1.2.1
What browsers are you seeing the problem on?
Firefox
If other, please specify.
No response
What operating system are you using?
macOS
๐งข Your Company/Team
No response
๐ท Tracking Issue
No response