fix(tool-bar): ensure tooltip labels are reliably announced for icon-only controls#3273
fix(tool-bar): ensure tooltip labels are reliably announced for icon-only controls#3273michal-sanoma wants to merge 9 commits into
Conversation
|
🕸 Website previewYou can view a preview here (commit |
🕸 Storybook previewYou can view a preview here (commit |
There was a problem hiding this comment.
Pull request overview
This PR updates the tool-bar Storybook stories to improve how icon-only controls are labeled for assistive technologies, focusing on tooltip-driven labeling patterns.
Changes:
- Removes a local disable for the
slds/button-has-labelESLint rule in the tool-bar stories file. - Updates tooltip-directive usage to explicitly use
ariaRelation: 'label'for icon-only buttons. - Adds explicit
aria-labelattributes to icon-onlysl-button/sl-menu-buttonexamples that also use tooltips.
Comments suppressed due to low confidence (2)
packages/components/tool-bar/src/tool-bar.stories.ts:545
- For
sl-menu-button, the hostaria-labelmay be forwarded to the innersl-button, but the explicitaria-labelledbystill takes precedence for the accessible name. If the goal is a reliable label fromaria-label, consider usingaria-describedbyfor the tooltip hookup and leavingaria-labelas the name source.
<sl-menu-button aria-label="Settings" aria-labelledby="tooltip-settings" fill="outline">
<sl-icon name="far-gear" slot="button"></sl-icon>
<sl-menu-item>
<sl-icon name="far-pen"></sl-icon>
Rename...
packages/components/tool-bar/src/tool-bar.stories.ts:558
- Same concern as the Settings menu-button: with both
aria-labelandaria-labelledbypresent,aria-labelledbywill generally override the newaria-label. If you wantaria-labelto be the stable accessible name and the tooltip to remain an additional hint, preferaria-describedbyfor the tooltip relation.
<sl-menu-button aria-label="Edit" aria-labelledby="tooltip-edit" fill="outline">
<sl-icon name="far-pen" slot="button"></sl-icon>
<sl-menu-item>
<sl-icon name="far-pen"></sl-icon>
Rename...
a11ymiko
left a comment
There was a problem hiding this comment.
Great work!
I'd like only to add aria-hidden='true' to each <span> that has tooltip's text. This way when user would use screen reader's Browse mode instead of Focus mode still only buttons with accessibility names would be focusable and spans would be ignored.
Is this possible to add this aria-haidden='true' for span?
|
Closing due to #3368 |
Summary
This PR fixes accessibility labeling in the Tool Bar stories where tooltip text was not consistently announced as the button name by screen readers.
Problem
In Tooltips and Icon Only stories, some icon-only controls relied on tooltip-based labeling only.
In certain browser/AT combinations, that setup is not reliably exposed as an accessible name.
Changes
Updated tooltip directive usage in the Tooltips story to use label relation (ariaRelation: 'label').
Added explicit aria-label fallbacks to icon-only sl-button and sl-menu-button examples in the tooltip-based Icon Only story.
Kept tooltip aria-labelledby wiring in place, so tooltip text still acts as the primary label where supported.
Removed an obsolete ESLint disable comment (slds/button-has-label).