fix: align grouped sticky headers #6472
beta fromrefs/pull/6472/head·opened 🎯 Changes#
Fix grouped sticky headers in the React column pinning example.
Grouped headers now derive their sticky side, offsets, width, and boundary shadow from the leaf columns rendered by the current header segment. This keeps mixed partial-pinning segments relative and aligns fully pinned groups when other pinned columns precede or follow them.
Add Playwright coverage for partial group pinning and non-zero start/end offsets.
Fixes #5397
✅ Checklist#
- I have followed the steps in the Contributing guide.
- I have tested this code locally with
pnpm test:pr.
Summary by CodeRabbit#
New Features
- Added support for grouped headers in the column-pinning example.
- Grouped headers now correctly reflect pinning when all visible child columns are pinned to the same side.
- Added sticky positioning and offset handling for grouped headers pinned to the start or end.
Tests
- Added end-to-end coverage for grouped-header pinning, alignment, dimensions, and sticky positioning.
- 1
This example previously had no grouped columns at all, firstName and lastName were flat top-level accessors, so there was actually no way to exercise sticky positioning for a group header before this PR. Wrapping them in an
infogroup is what exposes the bug in the first place,getCommonPinningStyles(column)was being called with the group's owncolumn, whosegetIsPinned/getStart/getAfterdon't reflect what its leaf columns are actually doing.I checked
header_getSizein table-core to confirmheader.getSize()on a group header already sums its leaf columns (sumHeaderSize), so using it directly aswidthfor the group is correct and explains why the tests expect the Info header to be ~360px (180+180) rather than the single-column 180.The "every leaf column must share the same pinned side" check in
getHeaderPinningStylesis the right call for deciding sticky vs relative. The first test nails exactly why: pin only First Name to start while Last Name stays unpinned, and since pinning tostartdoesn't reorder columns when the pinned one is already first, TanStack still renders Info as one merged header cell, just now with mixed-pinned leaves underneath. Without the "all leaves agree" check, that merged cell would likely have inherited a stale or partial sticky style. The test assertingposition: relativein that exact intermediate state is a good regression guard, and the second test showing Info splits into two separate header cells once First Name is pinned toend(because pinning to end physically reorders it away from Last Name) is a nice demonstration that the split itself is TanStack's own header-group logic doing its job, not something this PR has to handle manually.Using
firstLeafColumn.getStart('start')andlastLeafColumn.getAfter('end')instead of the group column's own offsets is correct since a group column has no size/position of its own outside of what its leaves contribute, and the boundingBox assertions comparing the sticky header'sxagainst the actual leaf header'sxare a good way to catch an off-by-one-column offset that a snapshot-only test would miss.Only thing I'd note is this all lives in an example, so it's more "here's the pattern to copy" than covered by table-core's own test suite, but for a docs example that's the right place for this logic to live since it's inherently presentational.
This example previously had no grouped columns at all, firstName and lastName were flat top-level accessors, so there was actually no way to exercise sticky positioning for a group header before this PR. Wrapping them in an
infogroup is what exposes the bug in the first place,getCommonPinningStyles(column)was being called with the group's owncolumn, whosegetIsPinned/getStart/getAfterdon't reflect what its leaf columns are actually doing.I checked
header_getSizein table-core to confirmheader.getSize()on a group header already sums its leaf columns (sumHeaderSize), so using it directly aswidthfor the group is correct and explains why the tests expect the Info header to be ~360px (180+180) rather than the single-column 180.The "every leaf column must share the same pinned side" check in
getHeaderPinningStylesis the right call for deciding sticky vs relative. The first test nails exactly why: pin only First Name to start while Last Name stays unpinned, and since pinning tostartdoesn't reorder columns when the pinned one is already first, TanStack still renders Info as one merged header cell, just now with mixed-pinned leaves underneath. Without the "all leaves agree" check, that merged cell would likely have inherited a stale or partial sticky style. The test assertingposition: relativein that exact intermediate state is a good regression guard, and the second test showing Info splits into two separate header cells once First Name is pinned toend(because pinning to end physically reorders it away from Last Name) is a nice demonstration that the split itself is TanStack's own header-group logic doing its job, not something this PR has to handle manually.Using
firstLeafColumn.getStart('start')andlastLeafColumn.getAfter('end')instead of the group column's own offsets is correct since a group column has no size/position of its own outside of what its leaves contribute, and the boundingBox assertions comparing the sticky header'sxagainst the actual leaf header'sxare a good way to catch an off-by-one-column offset that a snapshot-only test would miss.Only thing I'd note is this all lives in an example, so it's more "here's the pattern to copy" than covered by table-core's own test suite, but for a docs example that's the right place for this logic to live since it's inherently presentational.
The grouped-header pinning logic intentionally stays in the React example because it is presentation-specific. No code changes are required from this review.
biubiukam(GitHub profile, opens in a new tab) linked this to fix #5397
Sign in to join this conversation.
Important
Review skipped#
Auto reviews are disabled on base/target branches other than the default branch.
Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID:
11e63323-3892-419b-8c4d-1d26b494dd72You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
📝 Walkthrough
Walkthrough#
The sticky column-pinning example now supports grouped headers. It derives pinning styles from visible leaf columns, adds an
Infocolumn group, and tests mixed, start-pinned, and end-pinned grouped-header behavior.Changes#
Grouped header sticky pinning
examples/react/column-pinning-sticky/src/main.tsxInfogroup.examples/react/column-pinning-sticky/tests/e2e/smoke.spec.tsEstimated code review effort: 3 (Moderate) | ~20 minutes
Suggested reviewers:
kevinvandySequence Diagram(s)#
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
#5397.✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share