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

Enable tooltips to be used as accessible labels #211

Merged
merged 2 commits into from
Jul 17, 2024
Merged

Conversation

robintown
Copy link
Member

Currently, the only use case that our tooltip component supports is to describe another element. But it's arguably far more common in our products to use tooltips as an accessible label for an icon. I propose we change the default behavior of <Tooltip label={...}> to be that of a persistent accessible label, and use <Tooltip description={...}> for descriptive tooltips.

I took the liberty of changing the tooltip tests to use targeted assertions rather than snapshots, because in theory this makes for a less noisy test suite that is also better at communicating what properties we actually expect tooltips to have.

Closes element-hq/compound#322

Because we had two versions of @testing-library/dom in our dependency resolutions, @testing-library/user-event was failing to instrument fireEvent with act, causing tons of warnings and potentially broken test assertions.
Currently, the only use case that our tooltip component supports is to describe another element. But it's arguably far more common in our products to use tooltips as an accessible label for an icon. I propose we change the default behavior of <Tooltip label={...}> to be that of a persistent accessible label, and use <Tooltip description={...}> for descriptive tooltips.

I took the liberty of changing the tooltip tests to use targeted assertions rather than snapshots, because in theory this makes for a less noisy test suite that is also better at communicating what properties we actually expect tooltips to have.
@robintown robintown requested a review from a team as a code owner July 17, 2024 01:15
@robintown robintown requested review from dbkr and t3chguy and removed request for a team July 17, 2024 01:15
Copy link

Deploying compound-web with  Cloudflare Pages  Cloudflare Pages

Latest commit: ed4b75f
Status: ✅  Deploy successful!
Preview URL: https://3fc2e2df.compound-web.pages.dev
Branch Preview URL: https://tooltip-labels.compound-web.pages.dev

View logs

Copy link
Member

@t3chguy t3chguy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks sane

@robintown robintown merged commit 1b401be into main Jul 17, 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.

Compound Tooltips lack labels
2 participants