Skip to content

fix: bugs with pre-row models#6376

Merged
KevinVandy merged 1 commit into
betafrom
perf-pre-row-model
Jul 3, 2026
Merged

fix: bugs with pre-row models#6376
KevinVandy merged 1 commit into
betafrom
perf-pre-row-model

Conversation

@KevinVandy

@KevinVandy KevinVandy commented Jul 3, 2026

Copy link
Copy Markdown
Member

🎯 Changes

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm test:pr.

Summary by CodeRabbit

  • Bug Fixes

    • Corrected grouped and filtered selected-row behavior so selections now respect the current table state.
    • Fixed grouped row handling so every source row appears once in the grouped row model, including nested data and edge cases.
  • Tests

    • Added coverage for grouped row models, including nested rows, undefined grouping values, and missing columns.
    • Expanded selection tests to verify filtered and grouped selection results across the table pipeline.
  • Documentation

    • Updated performance tracking notes to reflect the completed fixes.

@nx-cloud

nx-cloud Bot commented Jul 3, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit d6526f0

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

☁️ Nx Cloud last updated this comment at 2026-07-03 17:53:04 UTC

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR fixes a duplication bug in createGroupedRowModel's terminal-depth branch that previously pushed rows twice, and corrects rowSelectionFeature.utils.ts to source filtered/grouped selected row models from filtered/sorted row models instead of core. New tests and perf tracker documentation updates accompany these fixes.

Changes

Row Model Bug Fixes

Layer / File(s) Summary
Terminal-depth grouping duplication fix
packages/table-core/src/features/column-grouping/createGroupedRowModel.ts, packages/table-core/tests/implementation/features/column-grouping/createGroupedRowModel.test.ts
groupUpRecursively no longer pushes the current row at terminal depth; only rewritten subRows are pushed into groupedFlatRows/groupedRowsById. New tests verify unique flat row IDs across single-level, two-level, tree-structured, undefined-valued, and nonexistent-column grouping scenarios.
Selected row model sourcing fix
packages/table-core/src/features/row-selection/rowSelectionFeature.utils.ts, packages/table-core/tests/implementation/features/row-selection/rowSelectionFeature.test.ts
table_getFilteredSelectedRowModel now sources from the filtered row model, and table_getGroupedSelectedRowModel sources from the sorted row model, replacing prior core row model usage. New pipeline tests validate filtered/grouped selection behavior, including when sorting is omitted.
Perf tracker updates
perf-done.md, perf-todo.md
Documents finding #102 (C9) as completed, moving its entry from the todo tracker to the done tracker with updated counts and audit notes.

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

Possibly related PRs

  • TanStack/table#6344: Overlaps with row-selection fixes in rowSelectionFeature.utils.ts around selected-row model construction and memoDeps correctness.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is related to the changes, but it is too vague to describe the specific row-model fixes. Rename it to mention the concrete fix, such as grouped/filtered selected row models or grouped row flattening behavior.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf-pre-row-model

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.

@pkg-pr-new

pkg-pr-new Bot commented Jul 3, 2026

Copy link
Copy Markdown
More templates

@tanstack/alpine-table

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

@tanstack/angular-table

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

@tanstack/angular-table-devtools

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

@tanstack/lit-table

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

@tanstack/match-sorter-utils

npm i https://pkg.pr.new/TanStack/table/@tanstack/match-sorter-utils@6376

@tanstack/preact-table

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

@tanstack/preact-table-devtools

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

@tanstack/react-table

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

@tanstack/react-table-devtools

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

@tanstack/solid-table

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

@tanstack/solid-table-devtools

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

@tanstack/svelte-table

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

@tanstack/table-core

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

@tanstack/table-devtools

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

@tanstack/vue-table

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

@tanstack/vue-table-devtools

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

commit: d6526f0

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (3)
packages/table-core/tests/implementation/features/row-selection/rowSelectionFeature.test.ts (1)

600-664: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Consider adding a fallback test for getFilteredSelectedRowModel without columnFilteringFeature.

The suite tests the grouped/sorted fallback path (Lines 645-663) but has no equivalent case verifying getFilteredSelectedRowModel() (which now calls table.getFilteredRowModel()) behaves safely on a table lacking columnFilteringFeature. Given the sourcing change discussed for rowSelectionFeature.utils.ts, a symmetric test would close the verification gap.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@packages/table-core/tests/implementation/features/row-selection/rowSelectionFeature.test.ts`
around lines 600 - 664, Add a fallback test for getFilteredSelectedRowModel in
rowSelectionFeature.test.ts that mirrors the grouped/sorted fallback coverage:
build a table from makePipelineTable without columnFilteringFeature, call
table.getFilteredSelectedRowModel(), and assert it still returns the selected
rows safely instead of failing. Use getFilteredSelectedRowModel,
makePipelineTable, and the pipelineFeatures override pattern to locate and
verify the fallback behavior introduced in rowSelectionFeature.utils.ts.
packages/table-core/src/features/column-grouping/createGroupedRowModel.ts (1)

90-96: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Minor style inconsistency: manual for-loop vs. forEach.

Rest of the function uses .forEach() for identical push patterns (lines 117, 185-188, 199-202). Using a plain for loop here is inconsistent but not incorrect.

♻️ Optional consistency tweak
         if (row.subRows.length) {
           row.subRows = groupUpRecursively(row.subRows, depth + 1, row.id)
-          for (let i = 0; i < row.subRows.length; i++) {
-            const subRow = row.subRows[i]!
+          row.subRows.forEach((subRow) => {
             groupedFlatRows.push(subRow)
             groupedRowsById[subRow.id] = subRow
-          }
+          })
         }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/table-core/src/features/column-grouping/createGroupedRowModel.ts`
around lines 90 - 96, The grouped row traversal in createGroupedRowModel is
using a manual for-loop for the same push pattern that the rest of the function
handles with forEach, so make this block consistent with the surrounding style.
Update the row.subRows handling inside groupUpRecursively to use the same array
iteration approach as the other groupedRowsById/groupedFlatRows population sites
in createGroupedRowModel, keeping the behavior unchanged while matching the
existing forEach style.
packages/table-core/src/features/row-selection/rowSelectionFeature.utils.ts (1)

250-250: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider documenting the fallback assumption here too.

Line 286 has a comment explaining the sorted-model fallback chain, but Line 250 has none. If table.getFilteredRowModel() also relies on a core fallback when columnFilteringFeature isn't registered, a short comment here would aid future readers and match the pattern at Line 284-285.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/table-core/src/features/row-selection/rowSelectionFeature.utils.ts`
at line 250, The row-selection fallback logic in rowSelectionFeature.utils.ts
should also document the assumption behind table.getFilteredRowModel(), since it
may fall back to the core row model when columnFilteringFeature is not
registered. Add a short explanatory comment near the rowModel assignment in the
rowSelection-related helper so the fallback chain is clear and consistent with
the existing sorted-model fallback comment, and reference the same selection
flow used by getFilteredRowModel and the nearby sorted-model logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/table-core/src/features/column-grouping/createGroupedRowModel.ts`:
- Around line 90-96: The grouped row traversal in createGroupedRowModel is using
a manual for-loop for the same push pattern that the rest of the function
handles with forEach, so make this block consistent with the surrounding style.
Update the row.subRows handling inside groupUpRecursively to use the same array
iteration approach as the other groupedRowsById/groupedFlatRows population sites
in createGroupedRowModel, keeping the behavior unchanged while matching the
existing forEach style.

In `@packages/table-core/src/features/row-selection/rowSelectionFeature.utils.ts`:
- Line 250: The row-selection fallback logic in rowSelectionFeature.utils.ts
should also document the assumption behind table.getFilteredRowModel(), since it
may fall back to the core row model when columnFilteringFeature is not
registered. Add a short explanatory comment near the rowModel assignment in the
rowSelection-related helper so the fallback chain is clear and consistent with
the existing sorted-model fallback comment, and reference the same selection
flow used by getFilteredRowModel and the nearby sorted-model logic.

In
`@packages/table-core/tests/implementation/features/row-selection/rowSelectionFeature.test.ts`:
- Around line 600-664: Add a fallback test for getFilteredSelectedRowModel in
rowSelectionFeature.test.ts that mirrors the grouped/sorted fallback coverage:
build a table from makePipelineTable without columnFilteringFeature, call
table.getFilteredSelectedRowModel(), and assert it still returns the selected
rows safely instead of failing. Use getFilteredSelectedRowModel,
makePipelineTable, and the pipelineFeatures override pattern to locate and
verify the fallback behavior introduced in rowSelectionFeature.utils.ts.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e644cc99-532e-4779-974c-42505a58918e

📥 Commits

Reviewing files that changed from the base of the PR and between bcac097 and d6526f0.

📒 Files selected for processing (6)
  • packages/table-core/src/features/column-grouping/createGroupedRowModel.ts
  • packages/table-core/src/features/row-selection/rowSelectionFeature.utils.ts
  • packages/table-core/tests/implementation/features/column-grouping/createGroupedRowModel.test.ts
  • packages/table-core/tests/implementation/features/row-selection/rowSelectionFeature.test.ts
  • perf-done.md
  • perf-todo.md

@KevinVandy KevinVandy merged commit bc8a8e8 into beta Jul 3, 2026
8 checks passed
@KevinVandy KevinVandy deleted the perf-pre-row-model branch July 3, 2026 17:54
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