Skip to content

feat(Table): pin group headings while their section is on screen - #6234

Merged
ernestt merged 5 commits into
core-table-sticky-headerfrom
core-table-sticky-group-headings
Sep 21, 2026
Merged

ernestt merged 5 commits into
core-table-sticky-headerfrom
core-table-sticky-group-headings

Conversation

@ernestt

@ernestt ernestt commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #6221 — review that one first; this PR's diff is only the last commit.

useTableGroupedRows takes hasStickyGroupHeaders. With it on, each group heading holds at the top of the table's scroll container until the next section pushes it out, so a reader scrolling deep inside a long group can still see which group they are in.

What it looks like

Same table, same scroll position, 48 people in four teams of twelve. Scrolled far enough into Infra that the heading has left the top of the list.

hasStickyGroupHeaders off on

On the left there is nothing on screen that says which team these people are on. On the right the heading is holding under the header row — at the header's measured height, not over it and not guessed.

Scrolled on both axes with useTableStickyColumns pinning Name, the heading stays above the pinned column and below the pinned header:

Why it needed both plugins

Pinning a heading vertically is not just position: sticky on the cell.

A sticky cell leaves its row behind, and the row is what carries the heading's fill — without a background of its own the pinned cell is transparent and the rows travelling under it show through. It also has to clear the body cells useTableStickyColumns pins at z-index: 1, or a pinned column paints over the heading as rows pass beneath it.

The offset is the part that needed the two plugins to cooperate. A heading pinned at the top of the scrollport lands on the header row useTableStickyHeader pins there too, and because tbody follows thead in the document the heading wins and hides it. There is no integer left between the sticky column's body cells at 1 and the pinned header at 2, so the fix is not a z-index but an offset: useTableStickyHeader now measures its header and publishes the height as --table-sticky-header-height on the scroll container, and a pinned heading starts below that. The two plugins already share --table-sticky-background, so this follows a path that exists.

Nothing to wire up. Install both and the heading comes to rest under the header; with no pinned header the variable is unset and the heading pins to the top edge, which is the right answer for a table that only pins its headings.

Both need a scrollport with somewhere to travel, which is what useTableStickyHeader's maxHeight is for — a container with no bounded height never scrolls itself, and a heading cannot pin to a scrollport it is not inside.

Verified

Measured in Storybook against the real plugins, not just in jsdom:

  • header pinned at top: 0, 37.5px tall, publishing --table-sticky-header-height: 37.5px
  • heading coming to rest at exactly 37.5px — flush under the header, no overlap
  • scrolled on both axes at once: the heading stays above the pinned column and below the pinned header, with the chevron held at the start edge

Two stories added under Core/TableGroupedRows, plus 7 tests: the option is off by default, on when asked, applies to every heading rather than only the first, survives renderGroupHeader, publishes the height, publishes nothing when the header is not pinned, and keeps publishing when useTableStickyColumns also holds the wrapper ref (that last one guards ref clobbering, which is the easy way to break this).

Follow-up to #6222

#6222 keeps the heading visible when the table is scrolled sideways. This is the same instinct on the other axis, split out because that one is a regression fix and this is a feature that depends on #6221.

Made with Cursor

useTableGroupedRows takes hasStickyGroupHeaders. With it on, each heading
holds at the top of the table's scroll container until the next section
pushes it out, so a reader scrolling deep inside a long group can still see
which group they are in.

A sticky cell leaves its row behind, and the row is what carries the
heading's fill, so the pinned cell needs a background of its own or the rows
travelling under it show through. It also sits at z-index 2 to clear the body
cells useTableStickyColumns pins at 1, which would otherwise paint over the
heading as rows pass beneath.

The offset needed the two plugins to cooperate. A heading pinned at the top
of the scrollport lands on the header row useTableStickyHeader pins there
too, and because tbody follows thead in the document the heading wins and
hides it. useTableStickyHeader now measures its header and publishes the
height as --table-sticky-header-height on the scroll container, and a pinned
heading starts below that — the same way the two plugins already share
--table-sticky-background. With no pinned header the variable is unset and
the heading pins to the top edge, which is right for a table that only pins
its headings.

Co-authored-by: Cursor <[email protected]>
@vercel

vercel Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Sep 21, 2026 5:33am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Sep 10, 2026
@astracat-bot

astracat-bot Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟡 Reviewed (for maintainers only) Sep 21, 2026, 5:37 AM UTC

HookParamDoc spells it `default`, not `defaultValue`. The docsite compiles
its generated registry against that type, so the wrong key only surfaced as
a Next.js type error in the Vercel build rather than anywhere local.

Co-authored-by: Cursor <[email protected]>

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for keeping the existing chevron size and legacy layout unchanged. I still don’t think this should add a public sticky-layout switch: the component already owns keeping its existing collapse action reachable. The current implementation also strands that button for custom headers after horizontal scrolling in both directions, clips it in vertical writing, and leaves the measured offset behind when the sticky-header plugin is removed. Could we keep the coordination internal and cover those compositions before exposing the behavior?

…eight

Per AST-025 FR1/FR3, resolve the logical block axis through the computed
writing mode before reading physical geometry. In vertical and sideways
writing modes the block axis is horizontal, so the published
--table-sticky-header-height is the thead's width there; the physical
height clipped pinned headings and the collapse control.
@ernestt
ernestt merged commit d1cb159 into core-table-sticky-header Sep 21, 2026
3 checks passed
@github-actions
github-actions Bot deleted the core-table-sticky-group-headings branch September 22, 2026 06:23

This branch was successfully deployed

1 active deployment
Preview — 5028f93d Deployed Sep 21, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant