Skip to content
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

"aria-hidden" does not work on Button component #6548

Open
mpalmer685 opened this issue Jun 14, 2024 · 3 comments
Open

"aria-hidden" does not work on Button component #6548

mpalmer685 opened this issue Jun 14, 2024 · 3 comments

Comments

@mpalmer685
Copy link

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 have aria-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

@rostero1
Copy link

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.

@snowystinger
Copy link
Member

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.

@marktnoonan
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants