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

Z-index guidelines #4407

Open
3 tasks
myrta2302 opened this issue Jan 9, 2025 · 4 comments · May be fixed by #4658
Open
3 tasks

Z-index guidelines #4407

myrta2302 opened this issue Jan 9, 2025 · 4 comments · May be fixed by #4658
Assignees
Labels
🍀 decision Marks conversations where a decision has been made 📦 styles Related to the @swisspost/design-system-styles package

Comments

@myrta2302
Copy link
Contributor

myrta2302 commented Jan 9, 2025

z-index variables:

In the styles\src\variables_commons.scss file we have:

$zindex-spinner: 990 !default;
$zindex-dropdown: 1000 !default; (top layer)
$zindex-sticky: 1020 !default;
$zindex-fixed: 1030 !default;
$zindex-modal-backdrop: 1040 !default; (top layer backdrop)
$zindex-modal: 1055 !default; (top layer)
$zindex-popover: 1060 !default; (top layer)
$zindex-tooltip: 1070 !default; (top layer)
$zindex-alert: 1080 !default; (top layer)
$zindex-header: 1090 !default;
...

Header z-index has been set so far with the custom property --header-z-index, usually with a default value of 10 (same value as post.ch header's z-index).

  1. Are there any general design guidelines for z-index?
  2. Should we have tokens for default z-index values?
  3. Cleanup of non used z-indices (e.g. #toplayer elements)
  4. Documentation needed?

Tasks

Preview Give feedback
@myrta2302 myrta2302 added the needs: 💬 pattern discussion This issue will be discussed in the next Pattern Discussion meeting. label Jan 9, 2025
@oliverschuerch oliverschuerch added needs: 🏓 dev roundtable To be discussed at the roundtable of esteemed developers and removed needs: 💬 pattern discussion This issue will be discussed in the next Pattern Discussion meeting. labels Jan 14, 2025
@oliverschuerch
Copy link
Contributor

We will not create any tokens for this.

@leagrdv leagrdv self-assigned this Jan 16, 2025
@gfellerph
Copy link
Member

Resolution: Create demo page to identify problematic use cases where two elements try to be on the top layer (open dialog with toast message) and try to figure out how we can control which takes precedence. Also, confirm with an example if e.g. dropdowns or tooltips work in an open dialog in the top layer.

@gfellerph gfellerph removed the needs: 🏓 dev roundtable To be discussed at the roundtable of esteemed developers label Jan 16, 2025
@leagrdv
Copy link
Contributor

leagrdv commented Jan 22, 2025

Here is a codepen testing multiple popovers on the same page: https://codepen.io/leamcg/pen/yyBxxKE

The behaviour with popover elements is that the most recent one to appear on the screen will always be placed on top of others within the #top-layer. Adjusting the z-index won't change the stacking order of these elements.

A popover inside another (e.g., a dialog within a dialog, or a tooltip inside a dialog) should not cause any issues. The child popover is not restricted by the parent. However, there is a potential concern with toasts and alerts, as they may end up appearing beneath a dialog backdrop, making them less visible. If the toast or alert is a popover, its visibility depends on when it appears relative to the dialog: if the toast appears before the dialog opens, it will be positioned behind it; if it appears after, it will be on top and clearly visible. A solution could be to listen to popovers appearing on the page and simply rerendering toasts when they do to make sure they are always on top. Though the native behavour might actually make sense - if a toast is visible and a user interacts with the UI to open a dialog, it's reasonable to assume the toast is less important and can be obscured.

@gfellerph
Copy link
Member

Proposed resolution: use top layer the standard way for components that can benefit from it (e.g. not the header megadropdown).

@gfellerph gfellerph added 🍀 decision Marks conversations where a decision has been made 📦 styles Related to the @swisspost/design-system-styles package labels Jan 22, 2025
@gfellerph gfellerph moved this from 👀 Triage to 💻 Ready for development in Design System Production Board Jan 22, 2025
@gfellerph gfellerph added this to the Maintenance III milestone Jan 22, 2025
@leagrdv leagrdv removed their assignment Jan 22, 2025
@leagrdv leagrdv self-assigned this Feb 11, 2025
@leagrdv leagrdv moved this from 💻 Ready for development to 🕹️ Coding in progress in Design System Production Board Feb 12, 2025
@leagrdv leagrdv linked a pull request Feb 12, 2025 that will close this issue
@leagrdv leagrdv moved this from 🕹️ Coding in progress to 🤬 Dev in Code Review in Design System Production Board Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍀 decision Marks conversations where a decision has been made 📦 styles Related to the @swisspost/design-system-styles package
Projects
Status: 🤬 Dev in Code Review
Development

Successfully merging a pull request may close this issue.

4 participants