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

Sticky header breaks when setting overflow in an parent element #820

Open
brentswisher opened this issue Oct 4, 2024 · 0 comments
Open

Comments

@brentswisher
Copy link
Contributor

Expected behavior
The header always stays sticky when scrolling vertically if hasStickyHeader is set to true

Actual behavior
The header will revert to its default relative positioning and not scroll with the table when overflow is applied to a parent node of the table. (This is often done on the table's container to enable horizontal scrolling.)

Steps to reproduce the issue

  1. Create a table with a sticky header
  2. Set something like overflow-x: scroll on the parent node of the container
  3. Scroll the table, and see the header no longer sticks to the top of the window as expected

Screenshots or code
Recording: https://github.com/user-attachments/assets/0a2532d4-6480-4b9a-98f0-77e20497078a

Pharos version
Latest develop branch (Unreleased change)

Your environment

  • OS: macOS
  • Browser: Chrome
  • Version: 129.0.6668.60

Additional information
This appears to be a known problem with using position:sticky and has a long running open issue in the css spec: w3c/csswg-drafts#865.

One option I considered was to add a fixed height to the table - but I don't think that will work in the context of a design system

Another is not using position:sticky and using a javascript based sticky header instead. That might be the best way forward, we are already using a InteractionObserver to set an active state, we could likely repurpose that to trigger a position: fixed at the appropriate time when hasStickyHeader is set, which would get around the issue altogether

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant