-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
Accessibility of Tooltip with disabled items #33182
Comments
@michaldudak Would |
It could, yes as it works by replacing the |
We're running into this issue as well, and accessibility is very important to us. Is there a workaround for this? |
any update for this issue? |
@joshkel A11y wise, is there a spec on how to deal with tooltips of disabled buttons? |
@sag1v I'm not aware of any:
Based on that, it sounds like the suggestion above of using However, to clarify, my issue is less "MUI's Tooltip isn't accessible when used with a disabled item," it's more "MUI's recommendation for letting Tooltip work with a disabled item interferes with accessibility, even if the item is enabled." In other words, I'm okay with accessibility of disabled items being not ideal (since it's not well-specified and there are significant tradeoffs in how to handle it), but it seems undesirable for core accessibility features of enabled items to suffer in the process. Personally, if Tooltip had some sort of
for enabled components and
for disabled components, I'd be happy. (E.g., maybe Tooltip could gain its own This is all my personal opinion - I'm not an a11y expert and could easily be missing considerations. |
Duplicates
Latest version
Summary 💡
I'm having trouble figuring out how to make accessibility work well with a Tooltip with disabled items.
If I follow the docs:
then Tooltip adds the label to the span instead of the button, and I get warnings from accessibility tools like Axe and Lighthouse that a span element probably shouldn't have an
aria-label
and that the button doesn't have anaria-label
.I can address the second issue by duplicating the label:
But then I'm having to duplicate text, and I have two elements with the same label, which may introduce other accessibility concerns. (For example, React Testing Library's
screen.findByLabelText
is no longer happy, and I assume some screen readers would read it twice.)Is there a clean way of fixing this? The only solution I can think of is for Tooltip to add some sort of
wrap
orallowDisabled
orWrapperComponent
prop that would cause it to use aspan
wrapper itself; that way, it could know the "real" child and inject the label or description there, while still having the wrapper it needs to let it work with a disabled child.Examples 🌈
See https://codesandbox.io/s/lucid-sound-oh0mnx?file=/src/App.tsx for an example.
Motivation 🔦
See above.
The text was updated successfully, but these errors were encountered: