Repository navigation
fix(core): add role="tooltip" to the Tooltip layer - #3243
Conversation
Addresses meta#3240. The Tooltip floating layer had no role, so it didn't complete the ARIA tooltip pattern (trigger already sets aria-describedby to the layer id) and test tooling had no stable selector for it. Add an optional role on the layer render props and pass role='tooltip' from useTooltip. +test asserting role + the aria-describedby link. Scoped to the Tooltip role (issue's meta#1 priority). HoverCard role, data-state, and data-testid forwarding are noted as follow-ups.
|
Someone is attempting to deploy a commit to the Meta Open Source Team on Vercel. A member of the Team first needs to authorize it. |
| '@astryxdesign/core': patch | ||
| --- | ||
|
|
||
| [fix] Tooltip: add `role="tooltip"` to the floating layer, completing the ARIA tooltip pattern (the trigger already links to it via `aria-describedby`). Also gives test tooling a stable, non-hashed selector for the layer (#3240). Plumbed via a new optional `role` on the layer render props. |
There was a problem hiding this comment.
I don't think this part is needed, since it can be assumed that the role is stable:
Also gives test tooling a stable, non-hashed selector for the layer (#3240)
There was a problem hiding this comment.
Done — trimmed that clause from the changeset.
Daniel15
left a comment
There was a problem hiding this comment.
This looks pretty good to me. It would be good to also update hovercards and popovers to have role="dialog".
I double-checked the layers for typeahead and tokenizer and verified that they already have role="listbox".
|
Thanks for the review! Addressed both:
Tooltip/HoverCard/Popover tests all green (44). |
cixzhang
left a comment
There was a problem hiding this comment.
Thanks! I can't believe we missed this.
Summary
Addresses #3240 (option 1, the priority ask). The
Tooltipfloating layer rendered with norole, so:aria-describedby→ layerid), andAdded an optional
roleto the layer render props (useLayerContextRenderProps→ popover element) and passrole="tooltip"fromuseTooltip. This is both an a11y correctness improvement and the testability hook the issue asks for.Testing
getByRole('tooltip'), contains the content, and the trigger'saria-describedbymatches the layerid.Tooltip7/7,HoverCard22/22,Popover14/14 pass — theuseLayerchange is additive (roleis optional, omitted when unset, so other layer consumers are unaffected).Scope / follow-ups
Kept this to the Tooltip
role(issue's #1). The issue's other asks are deferred as separate concerns:dialogimplies modal), so that's a design call.data-state="open|closed"— needs wiring the layer's open state into the render (reactive), a bigger change to the shared hook.data-testidforwarding — straightforward follow-up once the above direction is settled.Happy to do any of those if you'd like.
Changeset
Included (
@astryxdesign/corepatch).