Skip to content

Conversation

@ttkien
Copy link

@ttkien ttkien commented Nov 27, 2025

🎯 Changes

This pull request improves the row selection feature in the table core package by ensuring that selection and deselection operations respect the enableRowSelection configuration. It also adds comprehensive tests to verify this behavior for both selecting and deselecting all rows.

Bug Explanation:
When a row is selected and enableRowSelection is set to false, the row should remain selected because selection is supposed to be locked/disabled. However, when the user triggers Unselect All, the row becomes unselected even though selection is disabled.

Expected Behavior:
The row should remain selected when enableRowSelection = false, and the “Unselect All” action should not clear its selection state.

Actual Behavior:
The row is still unselected after “Unselect All,” meaning the selection state is not being preserved when selection is disabled.

Demo

tanstack-table-bug.mov

=> In demo, the row Barney should not be unselected

Testing Enhancements:

  • Added new tests in RowSelection.test.ts to verify that toggleAllRowsSelected correctly respects the enableRowSelection setting when selecting all rows, ensuring non-selectable rows remain unaffected.
  • Added tests to confirm that when deselecting all rows, rows that are not allowed to be deselected (according to enableRowSelection) retain their selection state.

✅ Checklist

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

🚀 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

    • Fixed row selection so bulk deselect now respects non-selectable rows, matching select-all behavior and preventing unintended changes.
  • Tests

    • Added tests covering bulk select/deselect to ensure non-selectable rows are consistently preserved.
  • Chores

    • Added release metadata entry documenting the fix for a patch release.

✏️ Tip: You can customize this high-level summary in your review settings.

@changeset-bot
Copy link

changeset-bot bot commented Nov 27, 2025

🦋 Changeset detected

Latest commit: 303bcd6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
@tanstack/table-core Patch
@tanstack/angular-table Patch
@tanstack/lit-table Patch
@tanstack/qwik-table Patch
@tanstack/react-table Patch
@tanstack/solid-table Patch
@tanstack/svelte-table Patch
@tanstack/vue-table Patch
@tanstack/react-table-devtools Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link

coderabbitai bot commented Nov 27, 2025

Walkthrough

Toggle-all deselect now skips rows where row.getCanSelect() is false, so non-selectable rows keep their selection entries. Tests and a changeset were added to cover and document this fix.

Changes

Cohort / File(s) Summary
Row selection logic
packages/table-core/src/features/RowSelection.ts
Adjusted toggleAllRowsSelected so the deselect-all branch checks row.getCanSelect() and skips rows that cannot be selected, preventing removal of their selection state.
Tests
packages/table-core/tests/RowSelection.test.ts
Added toggleAllRowsSelected tests verifying select-all and deselect-all respect enableRowSelection / getCanSelect() and leave non-selectable rows unchanged.
Release notes
.changeset/eleven-dingos-drum.md
Added a changeset entry describing the bug fix and requesting a patch release for @tanstack/table-core.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Review focus:
    • packages/table-core/src/features/RowSelection.ts — confirm the conditional skip logic is correct and has no unintended side effects.
    • packages/table-core/tests/RowSelection.test.ts — ensure tests correctly simulate selectable vs non-selectable rows and assertions reflect intended behavior.
    • .changeset/eleven-dingos-drum.md — verify the changeset content and package target.

Poem

🐇 I nudged the rows in morning light,
One said "no" and held on tight.
I cleared the rest but left that one,
Tests cheered softly — hop, job done! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main change: fixing toggleAllRowsSelected to respect row selection rules.
Description check ✅ Passed The description covers all required template sections with clear explanations of the bug, expected behavior, testing additions, and completed checklist items.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5fffb9a and 303bcd6.

📒 Files selected for processing (2)
  • packages/table-core/src/features/RowSelection.ts
  • packages/table-core/tests/RowSelection.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/table-core/src/features/RowSelection.ts
  • packages/table-core/tests/RowSelection.test.ts

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.

@ttkien ttkien changed the title feat(tests): add toggleAllRowsSelected tests to respect row selection rules fix : toggleAllRowsSelected should respect row selection rules Nov 27, 2025
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