-
Notifications
You must be signed in to change notification settings - Fork 40
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
Tooltip labeling #3094
Tooltip labeling #3094
Conversation
🦋 Changeset detectedLatest commit: 8f7d4d5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 7 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Storybook demoEndringer til review: 5b5c7cba5e | 88 komponenter | 139 stories |
I'll have to check more when I get to the office, but looks good so far. Also if the choice is between breaking change anyway vs breaking change + improvements I'd go for the latter 🙌 |
Do i understand this correct: The question is whether If
If
|
Yep thats a perfect summary of change/issue 💯 |
* Important: This will default to false in future major-versions | ||
* @default true | ||
*/ | ||
describeChild?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is "describesChild" clearer? (Added "s")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I notice the comment for this will then have lied about the future
"This will default to false in future major-versions" (so we should remove that 😅 )
My only "concern" about setting it to false by default, is that devs might not remember (or know) to change it to true when needed. Having it true by default will sometimes lead to repeated info for screen readers, but at least they will not miss any info? But I guess that's an edge case. Also, what about voice control? With describeChild=false it would be very important that the text in the Tooltip starts with the name text as the button does. (Btw, how is a11y assured for voice control users when only an icon is visible?) |
Based on the implementations looked through, i would argue that more info is left out for the screen-readers today with the avid use of Tooltip around non-interactive elements. By setting default to
Good question, i can do some testing and ask Morten 👍 |
@HalvorHaugan Did some testing with Mac voicecontrols: Screen.Recording.2024-08-14.at.13.46.28.mov
Since its shows a tooltip with the "accessible name" that is needed to trigger button i can't see it being a problem. Unless... the text is super long. As for that case, there is a setting where instead of labels, each element gets a number to remove this problem all together. Screen.Recording.2024-08-14.at.13.52.48.movThis is ofc only based on my testing so will need to talk to someone more experienced for how this is actually done. |
As long as the user follows this guideline: https://www.w3.org/TR/WCAG22/#label-in-name when combining a visual label with a tooltip (aria-label) it should pass requirements. This is not something we can control, but will need to document on the Tooltip documentation. |
Yes, I think my point was that it's not intuitive that the tooltip "overrides" the content by default. But I guess it's fine since this is typically not a problem based on how it's normally used, combined with good docs 👍 |
<Tooltip content="Skriv ut dokument" describesChild> | ||
<Button icon={<ArrowUpIcon aria-hidden />} /> | ||
</Tooltip> | ||
<Tooltip content="Skriv ut dokument" placement="right"> | ||
<Button icon={<ArrowRightIcon title="demo knapp" />} /> | ||
<Tooltip content="Skriv ut dokument" placement="right" describesChild> | ||
<Button icon={<ArrowRightIcon aria-hidden />} /> | ||
</Tooltip> | ||
<Tooltip content="Skriv ut dokument" placement="bottom"> | ||
<Button icon={<ArrowDownIcon title="demo knapp" />} /> | ||
<Tooltip content="Skriv ut dokument" placement="bottom" describesChild> | ||
<Button icon={<ArrowDownIcon aria-hidden />} /> | ||
</Tooltip> | ||
<Tooltip content="Skriv ut dokument" placement="left"> | ||
<Button icon={<ArrowLeftIcon title="demo knapp" />} /> | ||
<Tooltip content="Skriv ut dokument" placement="left" describesChild> | ||
<Button icon={<ArrowLeftIcon aria-hidden />} /> | ||
</Tooltip> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't describesChild
be false
in these cases? 🤔 (Same in some of the other examples)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like i flipped it when adding it to demo 🙈 I updated defaultValue to false
since this will be a breaking change anyways, and updated the examples 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you forget to update aksel.nav.no/website/pages/eksempler/togglegroup/with-tooltip.tsx?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Messed up the rebase 💥
Co-authored-by: Halvor Haugan <83693529+HalvorHaugan@users.noreply.github.com>
.changeset/little-files-cough.md
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Major?
Text should be updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Updated to major and added a TODO. Will write a section for v7 here https://aksel.nav.no/grunnleggende/kode/migrering.
For now i will create a feature-branch we can merge v7 changes into and change the base of this branch to that one.
* Tooltip labeling (#3094) * feat: Better labeling of Tooltip * feat: Better keyshortcuts for screenreaders in Tooltip * memo: Updated story * bug: Better error logging for example-parsing * refactor: describeChild -> describesChild * fire: Removed extra story * bug: removed extra tabIndex * memo: Update Tooltip demo description * Update aksel.nav.no/website/pages/eksempler/tooltip/labeling.tsx Co-authored-by: Halvor Haugan <83693529+HalvorHaugan@users.noreply.github.com> * refactor: Updated defaultValue for describesChild * bug: removed Tooltip prop from ToggleGroup --------- Co-authored-by: Halvor Haugan <83693529+HalvorHaugan@users.noreply.github.com> * Tailwind: Fixed 'screen' -> 'screens' bug to properly adopt breakpoints. (#3119) * 💥 Screen -> Screens in tailwind-config * refactor: Adopt updated screens-config in Aksel.nav.no project * Icons: Removed old and renamed icons (#3120) * 💥 Removed renamed icons * ErrorSummary: Add fallback for heading + better focus handling (#3140) Co-authored-by: Ken <ken.aleksander@gmail.com> Co-authored-by: Ken <26967723+KenAJoh@users.noreply.github.com> Co-authored-by: Halvor Haugan <83693529+HalvorHaugan@users.noreply.github.com> * feat: Added composeEventHandlers to onFocus in ErrorSummary * memo: Removed inaccurate description for tooltip demo * feat: Omitted tabIndex from ErrorSummary --------- Co-authored-by: Ken <26967723+KenAJoh@users.noreply.github.com> Co-authored-by: Ken <ken.aleksander@gmail.com>
Description
Resolves #3067
Really liked how MUI handled this interaction:
https://mui.com/material-ui/react-tooltip/#accessibility
By default now, the child element (i.e Button that Tooltip wraps around) will get
title
-attrb set to the Tooltip content when closes. When open, it will remove title and usearia-describedby
. By doing this the Tooltip will act as an extra description for the element, without overriding the button-content itself.If the user sets
describeChild={false}
now, the child element will instead getaria-label
set to the Tooltip-content. This will remain static between open-states. By doing this the Tooltip will always act as the label/name for the child-element. This is especially useful for Icon-buttons and similar elements.After merge i will update Tooltip docs with some notes on this prop and how to use it.
Discussion
I have now set the prop
describeChild
to default True, closer to todays implementation to reduce breaking changes. Issue is it still adds a small potential "breaking" change sincetitle
attrb is addedaria-describedby
is not merged with child-proparia-describedby
, it will not merge with Tooltiparia-describedby
. Might argue this shouldn't have been implemented in the first place, but might break some testsShould
describeChild
be default false?Since adding this change might have some breaking changes anyways, should it just be set to default false? All current Tooltip child-elements will get an
aria-label
with the Tooltip contents, but might argue that would be an improvement all around except in a few cases. Some tests might break, and some teams will have to update their Tooltip. Does this change fit into one of those small major-updates we have discussed?