-
Notifications
You must be signed in to change notification settings - Fork 19
chore(components): update tooltip to have accessible name #5551
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
chore(components): update tooltip to have accessible name #5551
Conversation
🦋 Changeset detectedLatest commit: d5614c8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 12 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 |
Related Previews |
…g-with-layout' of https://github.com/swisspost/design-system into 5458-bug-tooltip-host-element-not-hidden-and-interfering-with-layout
packages/components/src/components/post-tooltip-trigger/post-tooltip-trigger.tsx
Outdated
Show resolved
Hide resolved
if (node.nodeType === Node.TEXT_NODE) { | ||
return node.textContent?.trim() ?? ''; | ||
} | ||
if (node.nodeType === Node.ELEMENT_NODE) { | ||
const element = node as Element; | ||
return Array.from(element.childNodes) | ||
.map(child => this.extractText(child)) | ||
.join(' '); | ||
} | ||
return ''; |
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.
Imo a switch statement would fit your needs 100% here and also increase readability and performence.
https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Statements/switch
But also, where is this method used, I couldn't find any execution of it?
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.
You are right. I had a different implementation before (that added the text in an aria-label) and forgot to remove this code.
…-interfering-with-layout
…-interfering-with-layout
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.
We did the exact opposite in the the commit b16ba09.
That's why I would like to hear @gfellerph opinion about this change.
…-interfering-with-layout
…-interfering-with-layout
|
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.
Hi Myrta
As discussed before here, Philipp did the exact opposite in February 2024.

So my question still is, why did we change it back then and need to revert it now?
Will we fix one bug and open a new one with this change or should it fix the issue once and for all time?
Also we should explain the reason for the change in the changeset imo.
![]() I am not sure why it was moved before. The accessible name is visible in the Accessibility tab only when the |
When it's on the tooltip host, the tooltip is empty on startup because the popover is hidden. This gives an accessibility error of empty tooltip. With the role on the container, the thing works. My change was a regression. |
…-interfering-with-layout
|
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ `main` is currently in **pre mode** so this branch has prereleases rather than normal releases. If you want to exit prereleases, run `changeset pre exit` on `main`.⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ # Releases ## @swisspost/[email protected] ### Major Changes - Renamed the following CSS custom properties: - `--post-global-header-height` → `--post-global-header-expanded-height` - `--post-local-header-height` → `--post-local-header-expanded-height` - `--post-local-header-min-height` → `--post-local-header-expanded-min-height` (by [@alizedebray](https://github.com/alizedebray) with [#5933](#5933)) ### Minor Changes - Internalized bootstrap z-index utilities. (by [@hugomslv](https://github.com/hugomslv) with [#5741](#5741)) ## @swisspost/[email protected] ### Minor Changes - Enabled use of the `post-header` component without requiring a `post-mainnavigation`. (by [@alizedebray](https://github.com/alizedebray) with [#5933](#5933)) ### Patch Changes - Updated `<post-tooltip>` by moving the `role` attribute from the `<post-tooltip>` to the nested `<post-popovercontainer>` component to improve accessibility. (by [@myrta2302](https://github.com/myrta2302) with [#5551](#5551)) - Updated dependencies: - @swisspost/[email protected] - @swisspost/[email protected] ## @swisspost/[email protected] ### Minor Changes - Added icons: `2696` and `2697` (by [@swisspost-bot](https://github.com/swisspost-bot) with [#5993](#5993)) ### Patch Changes - Updated icons: - `help` (line & solid): 16, 24, 32, 40, 48 and 64px - `info` (line & solid): 16, 24, 32, 40, 48 and 64px - `success` (line & solid): 16, 24, 32, 40, 48 and 64px - `warning` (line & solid): 16, 24, 32, 40, 48 and 64px (by [@swisspost-bot](https://github.com/swisspost-bot) with [#6005](#6005)) ## @swisspost/[email protected] ### Patch Changes - Updated dependencies: - @swisspost/[email protected] ## @swisspost/[email protected] ### Patch Changes - Updated dependencies: - @swisspost/[email protected] ## @swisspost/[email protected] ### Patch Changes - Updated dependencies: - @swisspost/[email protected] ## @swisspost/[email protected] ## @swisspost/[email protected] ### Minor Changes - Internalized bootstrap z-index utilities. (by [@hugomslv](https://github.com/hugomslv) with [#5741](#5741)) ### Patch Changes - Enabled use of the `post-header` component without requiring a `post-mainnavigation`. (by [@alizedebray](https://github.com/alizedebray) with [#5933](#5933)) - Updated dependencies: - @swisspost/[email protected] - @swisspost/[email protected] - @swisspost/[email protected] - @swisspost/[email protected] - @swisspost/[email protected] - @swisspost/[email protected] ## @swisspost/[email protected] ### Patch Changes - Updated dependencies: - @swisspost/[email protected] - @swisspost/[email protected] ## @swisspost/[email protected] ### Patch Changes - Updated dependencies: - @swisspost/[email protected] ## @swisspost/[email protected] ### Patch Changes - Updated dependencies: - @swisspost/[email protected] - @swisspost/[email protected] - @swisspost/[email protected] ## @swisspost/[email protected] ### Patch Changes - Updated dependencies: - @swisspost/[email protected] --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
📄 Description
This PR updates the
<post-tooltip>
component to improve accessibility by moving therole
attribute from the<post-tooltip>
to the nested<post-popovercontainer>
component so that the text inside is correctly recognized as the accessible name.📝 Checklist