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

Handle sticky position with focus inside #4780

Open
gfellerph opened this issue Feb 25, 2025 · 1 comment · May be fixed by #4767
Open

Handle sticky position with focus inside #4780

gfellerph opened this issue Feb 25, 2025 · 1 comment · May be fixed by #4767
Assignees
Labels
💜 accessibility 🐞 bug Something isn't working 📦 components Related to the @swisspost/design-system-components package Header Everything related to our composible header components
Milestone

Comments

@gfellerph
Copy link
Member

gfellerph commented Feb 25, 2025

          This is a good idea, but it leaves us with the issue that the controls are still focusable. Earlier, I was thinking that we should not make them focusable by hiding them with `display: none`, but that leaves us with the issue that we don't know what to do with these controls when they are only partially visible.

I think a better idea would be to only apply the sticky behaviour when the focus is not inside the global navigation. When the page is scrolled, header is sticky, and the user navigates to the language switch via keyboard, we should show the header in full to make sure everything is properly visible. I think that could be done through CSS alone, making it more reliable.

.global-nav:focus-within {
  // Reset all sticky styles
}

// Or the opposite
.global-nav:not(:focus-within) {
  // Sticky styles
}

Originally posted by @gfellerph in #4767 (comment)

Since we're using position: sticky on the .global-header and on the .local-header elements, we can simply override the point, when they get sticky to inset-block-start: 0px for the .global-header and inset-block-start: var(--global-header-height) for the .local-header element to show them as if we were scrolling to the top.

@gfellerph gfellerph added this to the PPNL Support milestone Feb 25, 2025
@gfellerph gfellerph added 💜 accessibility Header Everything related to our composible header components 🐞 bug Something isn't working 📦 components Related to the @swisspost/design-system-components package labels Feb 25, 2025
@gfellerph
Copy link
Member Author

:has(.global-sub:focus-within),
:has(.local-sub:focus-within) {
--show-header-full: 0;
}

@leagrdv leagrdv self-assigned this Feb 26, 2025
@leagrdv leagrdv moved this from 👀 Triage to 🤬 Dev in Code Review in Design System Production Board Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💜 accessibility 🐞 bug Something isn't working 📦 components Related to the @swisspost/design-system-components package Header Everything related to our composible header components
Projects
Status: 🤬 Dev in Code Review
2 participants