-
Notifications
You must be signed in to change notification settings - Fork 507
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
Using TooltipV2
always sets aria associations on first child element
#4525
Comments
Hi @marywhite! Thanks for taking the time to file an issue! I think we usually discourage using tooltips in Forms in favor of visible captions (cc @mperrotti and @khiga8 to add nuance if needed!) Questions for you:
Some information for maintainers: (Not sure if this is a good idea yet) If you are using FormControl, the label should have a On our end, we can explore a solution where Tooltip and FormControl know of each other and wire up Before we get into that, we first need to verify if this is a good direction from the view of design and accessibility. |
This comment has been minimized.
This comment has been minimized.
@siddharthkp Agreed that always persistent visible labels are preferred whenever possible. In scenarios where having a persistent label is difficult (e.g. there is no space in the design), then we recommend at least having a tooltip provide a visible label (*with the caveat that some mobile users may still not be able to access it). The same concern applies for things like Icon Buttons Here's a screenshot of the scenario we're looking at. This may require some design input/updates to move to persistent labels 👀 . |
Ah I see! I should have asked for the use case before I suggested FormControl, my bad 😅 @broccolinisoup Do you have ideas? Also, does this trigger validation rules for interactive elements if we wrap it around the label instead of input? https://github.com/primer/react/blob/main/packages/react/src/TooltipV2/Tooltip.tsx#L171-L186
Sorry, can you tell me a bit more? @khiga8 |
@siddharthkp - the radio input is a child of the label, so I think it bypasses that validation. I wonder if the label could be considered interactive in this case though, as HTML labels support mouse events to select the corresponding radio control. |
@siddharthkp sorry my wording might've been confusing! Whenever we use a control represented by only be an icon, it is ideally supplemented by a tooltip so that users have access to a text alternative in scenarios where the meaning of the icon isn't clear! In this scenario, some color blind users may have trouble selecting the color so tooltips provide value. I believe in PVC (and maybe Primer React?), IconButtons come with a tooltip by default for this reason. That said, tooltips still do come with the caveat that mobile users might not have access, so persistent text is the most accessible. |
@khiga8 thanks for the explanation, now I understand 😇
Ah, I didn't realise the check also includes nested children. very cool @broccolinisoup!
Yep, same! Happy to follow @broccolinisoup's or @khiga8's lead on this |
Back to the problem at hand, I see two options:
Let me know if this is confusing, happy to set up a small prototype! Can you also link to the code that you are using for this implementation, just to make sure I understand the details correctly. |
@siddharthkp thank you for the suggestion! I had not though of using a custom label element to remove these aria attributes. I went ahead and implemented this in https://github.com/github/github/pull/323137. Let me know if this aligns with what you were thinking! |
Hello 👋 Sorry for the late reply! Love what @siddharthkp suggested ✨ and glad to hear that it is working for your case @marywhite.
I like this! I would say we should wait to see if there are other similar cases then can look into baking into Tooltip. @marywhite if your issue is resolved and you don't have further questions, can I close the issue? |
Yes, thanks @broccolinisoup! Feel free to close 😄 |
I have a use case where I'd like to use
<TooltipV2 />
with a label as the trigger element. In this scenario, the label element serves as the mouse target for a radio input. This results inaria-labelledby
/aria-describedby
(depending on the variant) getting set on the label element.Example markup (removing style and class attributes):
I'd like to instead set
aria-describedby
/aria-labelledby
on the input element. Is this a pattern that could be considered for the TooltipV2 API?The text was updated successfully, but these errors were encountered: