Skip to content
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

Avoid chaining aria-labelledby on tooltips #255

Merged
merged 1 commit into from
Oct 1, 2024
Merged

Conversation

robintown
Copy link
Member

aria-labelledby cannot be chained. So, it's not good practice to be setting aria-labelledby on both the anchor and the tooltip element.

The basic issue that I believe initially motivated the chaining was to distinguish the caption from the main tooltip content (by setting both aria-labelledby and aria-describedby on the tooltip element), so that the caption would not be considered part of the anchor's accessible label. But this was never actually working. The only good solution seems to be setting aria-labelledby and aria-describedby on the anchor to point directly to the label and caption elements.

aria-labelledby cannot be chained (https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-labelledby#benefits_and_drawbacks). So, it's not good practice to be setting aria-labelledby on both the anchor and the tooltip element.

The basic issue that I believe initially motivated the chaining was to distinguish the caption from the main tooltip content (by setting both aria-labelledby and aria-describedby on the tooltip element), so that the caption would not be considered part of the anchor's accessible label. But this was never actually working. The only good solution seems to be setting aria-labelledby and aria-describedby on the anchor to point directly to the label and caption elements.
@robintown robintown requested a review from a team as a code owner October 1, 2024 14:33
@robintown robintown requested review from dbkr and removed request for a team October 1, 2024 14:33
Copy link

Deploying compound-web with  Cloudflare Pages  Cloudflare Pages

Latest commit: 72aa36a
Status: ✅  Deploy successful!
Preview URL: https://20a1af9a.compound-web.pages.dev
Branch Preview URL: https://no-label-chaining.compound-web.pages.dev

View logs

@robintown
Copy link
Member Author

Thanks for the fast review 😄

@robintown robintown merged commit 22b2de4 into main Oct 1, 2024
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants