-
-
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
[Tooltip] displaying twice when used with SVG icon #25882
Comments
Unless I'm missing something, this is enough, for the given situation, cc @eps1lon import React from "react";
import CheckIcon from "@material-ui/icons/CheckCircle";
import { Tooltip } from "@material-ui/core";
export default class Demo extends React.Component {
render() {
return (
<div tabIndex={-1}>
<Tooltip title="My tooltip">
<CheckIcon aria-hidden={undefined} />
</Tooltip>
</div>
);
}
} https://codesandbox.io/s/material-ui-tooltip-icon-forked-yhsyz?file=/demo.js:0-358 |
This should be the default. The Tooltip should give the icon an accessible name. All you need to do is make sure the wrapped element is part of the a11y tree. In our case this would be Considering our default |
Thanks @oliviertassinari @eps1lon, that example actually throws a typescript error. Apologies I probably should have looked for a Typescript codesanbox. Want me to update or can you see the same in your Typescript environment? |
Yeah, we really should solve that at the icon level. |
@cmacdonnacha I have updated my first comment with |
Excellent thanks @oliviertassinari . That doesn't seem to give the icon an |
Regarding the history of the a11y of this component, we seem to inherit #6829. |
Hey guys, should I also add a
|
You neither need |
Nope I'm good with that, as long as a screen reader knows what the |
I'm keeping it open since that is a legitimate a11y issue with SvgIcon. Ideally |
Yea good point 👍 |
Working on this 🙂 |
So what I can get from the above conversation is that we should set the |
Related, but I wish that SvgIcon just used the Tooltip component in the first place rather than the title element, rather than needing to wrap it like this everywhere. |
If this is a common pattern, then I would recommend you abstract it into a separate component that composes the Tooltip and SvgIcon. Using the Tooltip by default in the SVGIcon penalizes every usage of SVGIcon that doesn't use a Tooltip. |
And that's what I'm doing, it just loses us the convenience of simply using the icon directly. It's frustrating to want to use the |
In order to have both a styled tooltip and an accessibility friendly icon I am using the
Tooltip
component along with settingtitleAccess
on theIcon
component, but now two tooltips appear when hovering over. I know that by removingtitleAccess
from the icon component it will prevent this but then you have a poor accessibility experience.Current Behavior 😯
Two tooltips appear when hovering over
Expected Behavior 🤔
Only one should appear
Steps to Reproduce 🕹
https://codesandbox.io/s/material-ui-tooltip-icon-forked-ox00e?file=/demo.js
Steps:
Context 🔦
Trying to have both a styled tooltip and an accessibility friendly icon so screen readers know what the icon represents.
Your Environment 🌎
See reproduction
The text was updated successfully, but these errors were encountered: