Skip to content

feat(row-model)!: group expansion defaults to expanded - #350

Merged
blove merged 2 commits into
mainfrom
blove/grouping-default-expanded
Aug 13, 2026
Merged

blove merged 2 commits into
mainfrom
blove/grouping-default-expanded

Conversation

@blove

@blove blove commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Groups now start expanded. Closes the open decision on #327.

What this restores

grid-core shipped groupsDefaultExpanded ?? true for the entire life of the grouping feature. The incremental row model's createExpansionRoot fell back to { kind: "collapsed" } instead, and because the option was renamed from a boolean to a policy object at the same time, the flip rode along unremarked. Nobody chose collapsed on the merits.

Why expanded is right, not just previous

Grouping in pretable is an interactive act as much as a configuration one — the user drags a column into the group panel while reading their rows. Collapsing on drop makes the data they were just looking at disappear at the moment they acted.

The comparison, verified in the installed packages rather than from memory:

default source
AG Grid 36.1.0 groupDefaultExpanded: 0 → collapsed its own gridOptionsDefault and runtime bundle
TanStack Table 9.1.2 getDefaultExpandedState() → empty map → collapsed rowExpandingFeature.utils
MUI x-data-grid 9.11.0 not verifiable locally — grouping is Premium —

So this deliberately diverges from both comparators I could check. The reason is that in those, grouping is typically developer configuration applied before the user arrives, where collapsed is a sensible landing state. { kind: "through-depth", depth } remains the escape hatch for populations too large to open at once.

The documentation gap that hid it

grouping.mdx described all three policies and never said which you get by omission. That silence is why a shipped behaviour change went unnoticed for a day. It now leads with the default.

Test changes, and why each is not a papering-over

Six tests failed. None of them were asserting the default on purpose except one:

  • expansion.test.ts > defaults collapsed… — renamed and inverted. This is the test that pinned the old behaviour; it now pins the new one, and additionally asserts an explicitly-collapsed model still yields 2 visible rows.
  • Four override-semantics tests did setGroupExpanded(x, true) expecting an override to be created. Under an expanded default that is a no-op, which is correct. They now pass { kind: "collapsed" } explicitly, so they keep testing override storage relative to a default rather than inheriting whichever one ships — the same class of bug this PR fixes.
  • grouping.test.ts > …collision-proof reads groups out of range(0, 20). 11 groups over 12 rows is 23 visible once expanded, so a 20-row window silently truncated to 10. Widened to range(0, 100); the test is about group identity and has nothing to do with expansion.
  • server-authority-aria.test.tsx > downgrades to the loaded model count moves aria-rowcount 3 → 5: two group rows, two data rows, one header. The rule it pins is unchanged — the external total of 5432 is still not published while grouping is active.

Not in scope

The bench needs no change: its group plan predicts rows + groupCount, which is correct again under an expanded default, so the 2026-08-10 grouping milestone stays comparable rather than needing a re-measure. I did not pin initialExpansion in the bench even though pinning is good practice, because #327 means grouping does not currently apply there at all and I could not verify the change end to end.

Verification

row-model 311, react 828, website 368, core 7, bench 128 — all pass. pnpm build && pnpm api:check clean, so the public surface is unchanged; this is a behavioural change to a documented default, carried by a minor changeset.

🤖 Generated with Claude Code

blove added 2 commits August 12, 2026 21:34
Restores the default #321 changed by accident. grid-core shipped
`groupsDefaultExpanded ?? true` for the whole life of the grouping
feature; the incremental row model's `createExpansionRoot` fell back to
`{ kind: "collapsed" }`, and the rename from a boolean to a policy object
carried the flip along with it unremarked.

Expanded is also the right default here, not merely the previous one.
Grouping in pretable is an interactive act as much as a configuration one
— the user drags a column into the group panel while reading their rows —
and collapsing on drop hides the data they were just looking at. AG Grid
(`groupDefaultExpanded: 0`, verified in its shipped defaults) and TanStack
(empty expanded map, verified in source) both default collapsed, but in
those grouping is typically developer configuration applied before the
user arrives. `{ kind: "through-depth" }` remains the escape hatch for
populations too large to draw at once.

The docs described all three policies and never said which you get by
omission. That silence is why a shipped behaviour change went unnoticed;
grouping.mdx now states it.

Tests that depended on starting collapsed now say so explicitly rather
than inheriting whichever default ships — which is the same class of bug
this commit fixes. aria-rowcount under grouping moves 3 -> 5 (two group
rows, two data rows, one header); the rule it pins is unchanged, in that
the external total is still not published while grouping is active.
@vercel

vercel Bot commented Aug 13, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
pretable Ready Ready Preview Aug 13, 2026 4:35am

@github-actions

Copy link
Copy Markdown
Contributor

Vercel preview ready

Preview: https://pretable-9a35txe15-cacheplane.vercel.app
Commit: 4e0750c68ee88a78f92f2e90cbfa685128a1aa7b

Updated automatically by the deploy-preview job.

@blove
blove merged commit 65d0365 into main Aug 13, 2026
16 checks passed
@blove
blove deleted the blove/grouping-default-expanded branch August 13, 2026 04:44
@blove blove mentioned this pull request Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant