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

[components]: Tooltip refactoring #4170

Open
3 of 5 tasks
gfellerph opened this issue Dec 6, 2024 · 1 comment
Open
3 of 5 tasks

[components]: Tooltip refactoring #4170

gfellerph opened this issue Dec 6, 2024 · 1 comment
Assignees
Labels
📦 components Related to the @swisspost/design-system-components package v8

Comments

@gfellerph
Copy link
Member

gfellerph commented Dec 6, 2024

There are several issues concerning tooltips that need to be fixed with a refactoring for the tooltip component.

Current state

The PR #3196 tried to introduce a new structure to tooltips, that does not require any mutation observers to make the API more stable. It was created a while ago and is not in a mergeable state. The main goal was to get rid of mutation observers to make the implementation more performant and bullet-proof. According to the reviews from @alizedebray, a slotchange listener might still be necessary to ensure the correct aria attributes are set on the trigger element.

Issues

  • Mutation observers for the attribute make the solution harder to implement than it needs to be, a wrapper custom element around the trigger provides us with a lifecycle hook to register event listeners and ensure accessibility on the trigger. This should fix Tooltips sometimes not showing #3042
  • Mouse movement between the trigger and the tooltip is not consistent. The goal is to establish a safe area where the mouse can move from the trigger to the tooltip without closing the tooltip. This is currently achieved with an invisible border around the tooltip, but it does not work properly. A small gap results in the tooltip closing in some situations and staying open in others. Add optional safe triangle to <post-popovercontainer> #4169 should help fixing this issue and the border can be removed from the tooltip.
  • The existing PR is so old that it cannot be merged easily anymore
  • [to be discussed] Linking elements via id is not as practical as it often seems. Ids have to be unique on the page and in some cases, it's difficult to ensure uniqueness. Using a custom attribute, e.g. post-target and post-name has the benefit of not using built in attributes and is not limited by browser restrictions, although the requirements on uniqueness are similar since users need to be specific about which tooltip element needs to be targeted
  • Boolean attributes should not be true by default, the tooltip arrow property breaks this rule

Tasks

Preview Give feedback
  1. 0 of 1
    📦 components
    schaertim
@gfellerph gfellerph added the 📦 components Related to the @swisspost/design-system-components package label Dec 6, 2024
@gfellerph gfellerph added this to the Design v2 milestone Dec 6, 2024
@gfellerph gfellerph added the v8 label Dec 18, 2024
@gfellerph gfellerph moved this from 👀 Triage to 💻 Ready for development in Design System Production Board Dec 18, 2024
@alionazherdetska alionazherdetska self-assigned this Jan 16, 2025
@alionazherdetska alionazherdetska moved this from 💻 Ready for development to 🕹️ Coding in progress in Design System Production Board Jan 22, 2025
@alionazherdetska alionazherdetska added the needs: 🏓 dev roundtable To be discussed at the roundtable of esteemed developers label Jan 23, 2025
@gfellerph
Copy link
Member Author

Resolution: use id to connect trigger and tooltip, alternatively a tooltip can be nested inside the trigger, removing the need for an id connection.

@gfellerph gfellerph removed the needs: 🏓 dev roundtable To be discussed at the roundtable of esteemed developers label Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 components Related to the @swisspost/design-system-components package v8
Projects
Status: 🕹️ Coding in progress
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants