Skip to content

fix: row selection method cloning bug#6314

Merged
KevinVandy merged 1 commit into
betafrom
fix-row-selection-cloning
Jun 11, 2026
Merged

fix: row selection method cloning bug#6314
KevinVandy merged 1 commit into
betafrom
fix-row-selection-cloning

Conversation

@KevinVandy

@KevinVandy KevinVandy commented Jun 11, 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

Release Notes

  • Bug Fixes
    • Fixed row selection to correctly include selected descendant rows even when their parent row is not selected. Row prototype methods are now properly preserved during selection operations.

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR fixes a bug in the row selection feature's selectRowsFn where selected descendants were dropped if their parent row was not selected. The implementation now unconditionally recurses through all rows and preserves row prototype methods using Object.create instead of object spread syntax, with supporting regression tests added.

Changes

Row Selection Bug Fix

Layer / File(s) Summary
Row selection recursion and prototype preservation
packages/table-core/src/features/row-selection/rowSelectionFeature.utils.ts
The selectRowsFn now always recurses into subRows and includes rows in the result set only if they are selected themselves, ensuring selected descendants are collected independently of parent selection. When constructing cloned selected rows with subRows, the function uses Object.create(Object.getPrototypeOf(row)) + Object.assign to preserve the original row's prototype chain instead of object spread. The per-iteration row binding is also changed from let to const.
Regression tests for descendants and prototypes
packages/table-core/tests/implementation/features/row-selection/rowSelectionFeature.test.ts
Two new test cases verify that selectRowsFn correctly returns selected descendants even when parent is unselected, and that cloned parent rows preserve row prototype methods like getValue.
Progress documentation update
perf.md
Progress counters are updated to reflect 20 completed findings (from 19), and finding #48 is marked done with implementation notes documenting the recursion/cloning fix and new regression tests.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A parent stays still, yet children may dance,
Their selections preserved by recursive branch,
Prototypes safe in their Object creation nest,
The clones inherit methods from their test! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: row selection method cloning bug' is directly related to the main change in the changeset, which fixes a cloning approach in the selectRowsFn to preserve row prototype methods.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 fix-row-selection-cloning

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 and usage tips.

@nx-cloud

nx-cloud Bot commented Jun 11, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit c983b23

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

☁️ Nx Cloud last updated this comment at 2026-06-11 03:30:53 UTC

@pkg-pr-new

pkg-pr-new Bot commented Jun 11, 2026

Copy link
Copy Markdown
More templates

@tanstack/angular-table

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

@tanstack/angular-table-devtools

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

@tanstack/lit-table

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

@tanstack/match-sorter-utils

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

@tanstack/preact-table

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

@tanstack/preact-table-devtools

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

@tanstack/react-table

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

@tanstack/react-table-devtools

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

@tanstack/solid-table

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

@tanstack/solid-table-devtools

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

@tanstack/svelte-table

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

@tanstack/table-core

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

@tanstack/table-devtools

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

@tanstack/vue-table

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

@tanstack/vue-table-devtools

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

commit: c983b23

@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 (1)
perf.md (1)

737-1738: 💤 Low value

Comprehensive and accurate documentation of the reframed fix.

The implementation note correctly identifies that the original proposed optimization (newSubRows !== row.subRows check) was flawed and explains the actual solution: unconditional recursion to collect selected descendants, cloning only selected parents, and prototype preservation via Object.create + Object.assign. The bug fix (spread syntax dropping the prototype chain) is well-documented and matches the pattern established in finding #49. Regression test additions are confirmed by the relevant code snippets.

Minor clarity suggestion: Line 738 mentions "The per-iteration row binding is also changed to const for immutability." The word "changed" suggests a transition from let to const, but the note doesn't show the before-state. If this was already const in the original code, consider rephrasing to "uses const" to describe the final state rather than implying a change. If it genuinely was changed from let, this is fine as-is.

🤖 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 `@perf.md` around lines 737 - 1738, The documentation's implementation note
states "The per-iteration row binding is also changed to const for
immutability." — update that sentence for clarity to either "uses const for
per-iteration row binding" if the final code already used const, or explicitly
state "changed from let to const for per-iteration row binding" if you did
perform the change; reference the sentence in the implementation note describing
the reframed fix (the paragraph explaining unconditional recursion, cloning only
selected parents, and prototype-preserving Object.create/Object.assign) so
readers know whether the wording describes the final state or an actual
transformation.
🤖 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 `@perf.md`:
- Around line 737-1738: The documentation's implementation note states "The
per-iteration row binding is also changed to const for immutability." — update
that sentence for clarity to either "uses const for per-iteration row binding"
if the final code already used const, or explicitly state "changed from let to
const for per-iteration row binding" if you did perform the change; reference
the sentence in the implementation note describing the reframed fix (the
paragraph explaining unconditional recursion, cloning only selected parents, and
prototype-preserving Object.create/Object.assign) so readers know whether the
wording describes the final state or an actual transformation.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e937874f-d8f8-4e49-b6d5-37b658dfbff7

📥 Commits

Reviewing files that changed from the base of the PR and between e25a532 and c983b23.

📒 Files selected for processing (3)
  • packages/table-core/src/features/row-selection/rowSelectionFeature.utils.ts
  • packages/table-core/tests/implementation/features/row-selection/rowSelectionFeature.test.ts
  • perf.md

@KevinVandy KevinVandy merged commit ab5c593 into beta Jun 11, 2026
8 checks passed
@KevinVandy KevinVandy deleted the fix-row-selection-cloning branch June 11, 2026 03:33
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