Skip to content

fix(table-core): preserve grouped flatRows preorder - #6576

Merged
KevinVandy merged 1 commit into
mainfrom
fix/grouped-row-model-preorder-flatrows
Aug 25, 2026
Merged

fix(table-core): preserve grouped flatRows preorder#6576
KevinVandy merged 1 commit into
mainfrom
fix/grouped-row-model-preorder-flatrows

Conversation

@KevinVandy

@KevinVandy KevinVandy commented Aug 25, 2026

Copy link
Copy Markdown
Member

🎯 Changes

Fixes #6551. Supersedes #6552 while retaining Lazizbek Ergashev's contribution via co-author credit.

  • Emit grouped flatRows in parent-first preorder for flat and hierarchical data without adding another grouping traversal.
  • Preserve parent-first ordering in grouped worker reconstruction.
  • Deduplicate expanded worker reconstruction and rebuild its flatRows from the completed tree, fixing an additional downstream ordering failure found during the pipeline audit.
  • Add exact grouped and worker round-trip regressions plus one invariant test covering core, filtered, grouped, sorted, expanded, and paginated row models.

Performance and bundle impact: the synchronous grouping path remains O(rows) and uses its existing recursive pass; synthetic groups reserve their output slot before descendants are built. Expanded worker reconstruction adds one O(rows) traversal and a temporary Set only when rebuilding an expanded tree payload, replacing duplicated output entries with one parent-first entry per row. The production change is small and introduces no dependency or public API changes.

Validation:

  • pnpm test — 871 tasks passed
  • pnpm test:e2e — 407 tasks passed after the repository retry runner resolved nine flaky example tasks
  • pnpm --filter @tanstack/table-core test:types
  • focused row-model tests — 29 passed
  • ESLint, Prettier, and git diff --check

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with pnpm test and pnpm test:e2e, or these tests do not apply to this pull request.
  • I fully understand the code in this pull request, including any code generated with AI assistance.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Bug Fixes

    • Corrected flattened row ordering so grouped rows consistently appear before their descendants.
    • Preserved row identity and removed duplicate entries across filtering, sorting, expansion, pagination, and worker processing.
    • Improved consistency when rebuilding and serializing hierarchical row data.
  • Tests

    • Added coverage for preorder flattening and expanded grouped data across row-model stages.
  • Documentation

    • Updated performance notes to reflect the corrected row-ordering behavior.

Co-authored-by: Lazizbek Ergashev <lazerg2@gmail.com>
@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 966b0a38-f312-4964-97a9-38a0da8371b5

📥 Commits

Reviewing files that changed from the base of the PR and between 468f267 and 4df2ce9.

📒 Files selected for processing (7)
  • .changeset/tidy-groups-walk.md
  • packages/table-core/src/features/column-grouping/createGroupedRowModel.ts
  • packages/table-core/src/worker/rebuildRowModel.ts
  • packages/table-core/tests/implementation/core/row-models/rowModelFlatRowsOrder.test.ts
  • packages/table-core/tests/implementation/features/column-grouping/createGroupedRowModel.test.ts
  • packages/table-core/tests/unit/worker/serializeRebuild.test.ts
  • perf-new.md

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

Grouped and worker row models now emit flatRows in parent-before-descendant order. Expanded worker rebuilds reconstruct preorder rows and remove duplicate IDs. Tests cover grouped trees, pipeline stages, and serialization round trips.

Changes

Flat row ordering

Layer / File(s) Summary
Grouped row preorder flattening
packages/table-core/src/features/column-grouping/createGroupedRowModel.ts, packages/table-core/tests/implementation/features/column-grouping/createGroupedRowModel.test.ts, packages/table-core/tests/implementation/core/row-models/rowModelFlatRowsOrder.test.ts
Grouped traversal reserves each group position before descendants. Tests verify preorder ordering and unique IDs across row-model stages.
Worker preorder reconstruction
packages/table-core/src/worker/rebuildRowModel.ts, packages/table-core/tests/unit/worker/serializeRebuild.test.ts, .changeset/tidy-groups-walk.md, perf-new.md
Worker rebuilds flatten grouped and expanded trees in preorder. Serialization tests verify row identity and ordering. Changeset and performance notes document the correction.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 4df2c

The change preserves parent-first row ordering across grouped and worker-backed models with focused regression coverage; no actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 5 files. (2 skipped: 2 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: preserving preorder for grouped flatRows.
Description check ✅ Passed The description is complete. It explains the changes, motivation, performance impact, validation results, checklist status, and release impact. It also includes the required changeset information.
Linked Issues check ✅ Passed The implementation addresses issue #6551 by emitting grouped flatRows in parent-first preorder for flat and hierarchical data. It also preserves ordering through worker reconstruction and expanded or …
Out of Scope Changes check ✅ Passed The changes are within scope. Production changes, worker reconstruction updates, tests, the changeset, and performance documentation all support the stated grouped flatRows ordering objectives.
Full details: Linked Issues check

Explanation

The implementation addresses issue #6551 by emitting grouped flatRows in parent-first preorder for flat and hierarchical data. It also preserves ordering through worker reconstruction and expanded or paginated pipelines, with regression coverage.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 5 files. (2 skipped: 2 unsupported.)

✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/grouped-row-model-preorder-flatrows

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

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

1 package(s) bumped directly, 11 bumped as dependents.

🟩 Patch bumps

Package Version Reason
@tanstack/table-core 9.2.2 → 9.2.3 Changeset
@tanstack/alpine-table 9.2.2 → 9.2.3 Dependent
@tanstack/angular-table 9.2.2 → 9.2.3 Dependent
@tanstack/angular-table-devtools 9.2.2 → 9.2.3 Dependent
@tanstack/ember-table 9.2.2 → 9.2.3 Dependent
@tanstack/lit-table 9.2.2 → 9.2.3 Dependent
@tanstack/octane-table 9.2.2 → 9.2.3 Dependent
@tanstack/preact-table 9.2.2 → 9.2.3 Dependent
@tanstack/react-table 9.2.2 → 9.2.3 Dependent
@tanstack/solid-table 9.2.2 → 9.2.3 Dependent
@tanstack/svelte-table 9.2.2 → 9.2.3 Dependent
@tanstack/vue-table 9.2.2 → 9.2.3 Dependent

@nx-cloud

nx-cloud Bot commented Aug 25, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 4df2ce9

Command Status Duration Result
nx affected --targets=test:eslint,test:sherif,t... ✅ Succeeded 8m 54s View ↗
nx run-many --targets=build --exclude=examples/** ✅ Succeeded 1m View ↗

☁️ Nx Cloud last updated this comment at 2026-08-25 21:59:26 UTC

@pkg-pr-new

pkg-pr-new Bot commented Aug 25, 2026

Copy link
Copy Markdown
More templates

@tanstack/alpine-table

npm i https://pkg.pr.new/@tanstack/alpine-table@6576

@tanstack/angular-table

npm i https://pkg.pr.new/@tanstack/angular-table@6576

@tanstack/angular-table-devtools

npm i https://pkg.pr.new/@tanstack/angular-table-devtools@6576

@tanstack/ember-table

npm i https://pkg.pr.new/@tanstack/ember-table@6576

@tanstack/lit-table

npm i https://pkg.pr.new/@tanstack/lit-table@6576

@tanstack/match-sorter-utils

npm i https://pkg.pr.new/@tanstack/match-sorter-utils@6576

@tanstack/octane-table

npm i https://pkg.pr.new/@tanstack/octane-table@6576

@tanstack/preact-table

npm i https://pkg.pr.new/@tanstack/preact-table@6576

@tanstack/preact-table-devtools

npm i https://pkg.pr.new/@tanstack/preact-table-devtools@6576

@tanstack/react-table

npm i https://pkg.pr.new/@tanstack/react-table@6576

@tanstack/react-table-devtools

npm i https://pkg.pr.new/@tanstack/react-table-devtools@6576

@tanstack/solid-table

npm i https://pkg.pr.new/@tanstack/solid-table@6576

@tanstack/solid-table-devtools

npm i https://pkg.pr.new/@tanstack/solid-table-devtools@6576

@tanstack/svelte-table

npm i https://pkg.pr.new/@tanstack/svelte-table@6576

@tanstack/table-core

npm i https://pkg.pr.new/@tanstack/table-core@6576

@tanstack/table-devtools

npm i https://pkg.pr.new/@tanstack/table-devtools@6576

@tanstack/vue-table

npm i https://pkg.pr.new/@tanstack/vue-table@6576

@tanstack/vue-table-devtools

npm i https://pkg.pr.new/@tanstack/vue-table-devtools@6576

commit: 4df2ce9

@KevinVandy
KevinVandy merged commit 3b94648 into main Aug 25, 2026
10 checks passed
@KevinVandy
KevinVandy deleted the fix/grouped-row-model-preorder-flatrows branch August 25, 2026 22:01
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.

getGroupedRowModel().flatRows puts every group row after all its descendants, not just tree data below terminal depth

1 participant