USWDS - Table component: add ability to make headers sticky as user scrolls#5074
USWDS - Table component: add ability to make headers sticky as user scrolls#5074etanb wants to merge 4 commits intouswds:developfrom
Conversation
|
@etanb Thank you for this submission! I like the possibilities this variant offers. I've added some notes on a few items I discovered. Would you be able to take a look and resolve these items?
Please let me know if you have any questions or comments! |
|
@etanb I have added the |
|
Thanks for the contribution @etanb! No issues found on mobile and browser support looks pretty good. https://caniuse.com/css-sticky Are you able to address Amy's comments? If you're unable to that's okay. We can create another issue for the comments and create a separate feature branch for all this work. What do you think @amyleadem? |
|
Hi all, I'm just rebuilding my local now and will have an update soon! Will try and incorporate all of @amyleadem requests. |
|
My latest commit #630eadc6913a3efa5a08e90049074add4a8f11a6 adds usage for all the other USWDS stylings except for Two remaining issues / items for y'all/us to decide on:
You can see that the row that are doubled up get squashed together since all Let me know what y'all think! cc @amyleadem @mejiaj |
|
Unfortunately, after digging deeper, having a horizontal scroll + a sticky header for a table has been a known issue for a while (2017!) and there's still an open issue on W3C CSS repo: w3c/csswg-drafts#865 The only workaround I see is removing and removing Example of it working: scrollAndSticky.mp4However, that's a lot of modifications to get this feature working. Let me know what y'all think and what is worthwhile! |
Yes it is a really old issue and I hope one day it could be fixed. We need a feature that allows overflow on height or width. But both overflows works and no one too. If we remove hidden overflow the table expands the viewport. It would be grate that setting an overflow hidden does not remove the sticky attribute so text outside the table stays on the view. It is especially good for mobile when the user can scroll inside the table without scrolling the whole page. |
|
Ok, not sure what next steps are here are @DorianCoding @amyleadem @mejiaj . My gut instinct here is to just make |
It already works when setting both width and height or none using overflow visible. |
|
If we have a fixed table height, you can have BOTH side scrolling + sticky header. |
|
@etanb I know some time has passed, so please let us know if your availability has changed and you need any help finishing this out. I have tested the following items:
Other considerations
cc: @mejiaj @mahoneycm |
|
Thanks for the extensive checklist @amyleadem. We're currently implementing on our variation of this feature on our site, and as said previously, using a fixed height (we do |
@etanb Thanks for the suggestion. I will take a look and discuss with the team. |
amyleadem
left a comment
There was a problem hiding this comment.
Hi @etanb,
Wanted to check in to see if you will be able to get to the items in the checklist in this comment.
I know a part of the conversation was left hanging on my part. Thanks for your patience with that. For now, lets move forward without including sticky tables on scrollable headers. We can always address that concern as a follow-on enhancement.
Just let us know if your availability has changed and you need us to finish this out.
|
That's exciting news! Thanks for making this happen @amyleadem , let me know if I can be useful. |
|
Absolutely! Thanks for your patience on this. |




Summary
For very long tables, it's difficult to remember what the header content was. This change allows a developer to have the the table header content follow a user on scroll.
Breaking change
This is not a breaking change.
Related issue
N/A
Preview link
FixedHeaderTable.mp4
Solution
usa-table--sticky-headerthat invokes the following CSS rule:(NOTE: you can not
position: sticky;a<thead>element so the preferred solution is to just target the<th>data.)Testing and review
Sticky Headerwhere you can review the results