-
Notifications
You must be signed in to change notification settings - Fork 585
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
fix: withTooltip accessibility #47
Conversation
@jsomsanith It is a good question. I just took a look and ultimately it looks like the places that used const Rect = styled.rect`
fill: rgb(255, 255, 0);
`;
<svg>
<WithTooltip svg {// and a bunch more props}>
<Rect x={left} y={top} width={width} height={height} />
</WithTooltip>
</svg> With that in mind, I tried applying the styles you used here to an element that was rendered that way and it doesn't seem to work. Maybe the svg needs the
Maybe there is a way to just do number 1 above without number 2 using just a div as you are suggesting, though it appears a bit more might be needed based on my limited testing. Could you write a story with the component hierarchy shown above ☝️ so we can capture this use case and see what is required to support it? Thanks & let me know if you have questions! 🙇 |
@kylesuss I don’t think we should control the element that is rendered. And I don’t think we should use
Using
If you prefer to keep the old api for compatibility for the svg, I can reintroduce it, adding an extra
I added a story with a valid |
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.
Amazing update. Thanks again for accommodating our svg use case 🎉
🚀 PR was released in v0.0.40 🚀 |
What is the problem this PR is trying to solve?
withTooltip
component is not accessibleWhat is the chosen solution to this problem?
<g>
tags. We introducedas
props, suggested by @kylesuss. It render a particular component instead of the button, adding button keyboard behavior manually in that case, and therole="button"
add
role="tooltip"
on tooltip divtrigger button has an
aria-controls
attribute to indicate that it opens the identified element, andaria-describedby
so SR will read the tooltip content on open.Bonus
REMOVE TOGGLE
Having 2 ways to trigger the tooltip (mouse and keyboard) revealed a problem with the state management because it was a toggle. Take this scenario:
Instead of toggling the state value, we now really let TooltipTrigger component control it, by setting the
isTooltipShown
value.MEMO
There are some function that are created at each render, creating a new reference everytime. Use React.memo to memoize them.