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

fix(guidelines): guidelines-icons-button-label-audit #7821

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ const TooltipDefinition = ({
type="button"
className={tooltipTriggerClasses}
aria-describedby={tooltipId}
aria-label={tooltipText}
Copy link
Contributor

Choose a reason for hiding this comment

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

Would this end up causes the same text (tooltipText) to be announced twice from both aria-label and aria-describedby

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@joshblack good point! aria-describedby announces the tooltipId which I think should be different from the text

Copy link
Contributor

Choose a reason for hiding this comment

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

@andreancardona I believe the way aria-describedby works is that it uses the id to find the DOM node from which it computes the description. In this case, using aria-label with the tooltipText would give the node the accessible name of tooltipText. It would also give the node the description of tooltipText from aria-describedby as it points to a node that contains that as its accessible label.

In the preview, we can see this in the accessibility tab:

image

Another issue that this can cause is that now the button no longer uses the underlying text as the label, so the user would only hear the tooltip text but would not know what that text it is defining.

onFocus={composeEventHandlers([onFocus, handleFocus])}>
{children}
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ exports[`TooltipDefinition should allow the user to specify the direction 1`] =
>
<button
aria-describedby="definition-tooltip-3"
aria-label="tooltip text"
className="bx--tooltip__trigger bx--tooltip--a11y bx--tooltip__trigger--definition bx--tooltip--top bx--tooltip--align-start"
onFocus={[Function]}
type="button"
Expand Down Expand Up @@ -45,6 +46,7 @@ exports[`TooltipDefinition should render 1`] = `
>
<button
aria-describedby="definition-tooltip-1"
aria-label="tooltip text"
className="bx--tooltip__trigger bx--tooltip--a11y bx--tooltip__trigger--definition bx--tooltip--bottom bx--tooltip--align-start"
onFocus={[Function]}
type="button"
Expand Down Expand Up @@ -77,6 +79,7 @@ exports[`TooltipDefinition should support a custom trigger element class 1`] = `
>
<button
aria-describedby="definition-tooltip-2"
aria-label="tooltip text"
className="bx--tooltip__trigger bx--tooltip--a11y bx--tooltip__trigger--definition custom-trigger-class bx--tooltip--bottom bx--tooltip--align-start"
onFocus={[Function]}
type="button"
Expand Down