UI Tooltip: Improve documentation to cover intended accessibility practices#76705
UI Tooltip: Improve documentation to cover intended accessibility practices#76705
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Size Change: 0 B Total Size: 7.66 MB ℹ️ View Unchanged
|
fcfc129 to
ab045e2
Compare
ciampo
left a comment
There was a problem hiding this comment.
I quite like Base UI docs on Tooltip, they have "Usage guidelines" and "Alternative to tooltips" sections.
I think this may even warrant a dedicated mdx page with a few interactive storybook examples of good practices, bad practices, and alternatives (eg use Popover for infotips)
| <> | ||
| <Tooltip.Trigger>Hover me</Tooltip.Trigger> | ||
| <Tooltip.Popup>Tooltip text</Tooltip.Popup> | ||
| <Tooltip.Trigger aria-label="Save">💾</Tooltip.Trigger> |
There was a problem hiding this comment.
I also feel that the examlpes could me more useful if they showed a different use case from the one already covered by IconButton?
There was a problem hiding this comment.
Did you have something in mind? I can't really think of a use case that isn't an icon button.
There was a problem hiding this comment.
Yeah 😅 Although this is telling on the real utility of Tooltip as a primitive, given that its main usecase is covered by Icon Button and that we don't recommend many other possible use cases
Making a standard infotip pattern/component has been on my todo list, but we currently don't have one yet, and the pattern doesn't exist in Gutenberg 😕 We also haven't aligned on guidance for status messaging. Those two are the most commonly misused patterns. So we actually don't have a lot of "do this instead of this" to officially showcase yet. It's mostly going to be "don't do this" at this point, so I'm thinking we can punt the more comprehensive guidance to later and first make the current docs not be misleading. Is that reasonable, or would you have anything particular to highlight at the moment? |
ciampo
left a comment
There was a problem hiding this comment.
As soon as Popover is added, could we reasonably add similar docs? We would only have a gap for the "Contextual feedback messages" section, but we could leave a "WIP" notive re. adding a toast component.
In the meantime, this PR is already definitely an improvement 🚀
Would love to add an infotip pattern or component for sure 👍 |
…ctices (#76705) * Tooltip: Add documentation and update story examples for accessibility * Use @wordpress/icons in WithProvider story example * Fix discoverability of link Co-authored-by: mirka <0mirka00@git.wordpress.org> Co-authored-by: ciampo <mciampini@git.wordpress.org>
…ctices (#76705) * Tooltip: Add documentation and update story examples for accessibility * Use @wordpress/icons in WithProvider story example * Fix discoverability of link Co-authored-by: mirka <0mirka00@git.wordpress.org> Co-authored-by: ciampo <mciampini@git.wordpress.org>
What?
Add a JSDoc description to the
Tooltipcomponent and update the Storybook examples to follow accessibility best practices.Why?
The Tooltip stories previously used text-labeled buttons as triggers, which doesn't reflect the intended use case. Tooltips are meant for controls that lack a visible text label (like icon buttons), and the trigger must be accessibly labeled independently of the tooltip.
We continue to see misuse and misunderstanding of what the
Tooltipcomponents do, and I think the documentation should be blamed first.How?
Tooltip.Rootdocumenting the component's purpose, touch device limitations, accessible labeling requirements, and a cross-reference toIconButton.@wordpress/iconsviaIcon) with explicitaria-labelattributes, demonstrating the recommended accessible pattern.Testing Instructions
See
Tooltipstories in Storybook (@wordpress/ui)AI tools
Actual accessibility guidance authored by me, examples improved on my guidance, executed by Opus 4.6