[BUG] ignore non expandable rows when the expanded state changes
๐ฏ Changes
Resolving the issue I bought up in https://github.com/TanStack/table/issues/6115 where if the old expanded state is true and you change any of the expanded rows. It will also include rows that don't have expanded rows. This was then causing a situation where the getExpandedDepth function was returning the wrong number as the state included rows that shouldn't have been included
I have just added a check to see if that row should be expandable before it gets added to the expandable state.
โ Checklist
- [x] I have followed the steps in the Contributing guide.
- [x] I have tested this code locally with
pnpm test:pr.
๐ Release Impact
- [x] 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
- Fixes the "expand all" behavior so only rows eligible for expansion are marked expanded; non-expandable rows are no longer added to the expanded state. Preserves single-row expansion behavior, external change handlers, and prevents unintended visual/state changes when toggling expand-all.
โ๏ธ Tip: You can customize this high-level summary in your review settings.
๐ฆ Changeset detected
Latest commit: 6ad1c8822213d8d13a04d18aa0760f32546df6da
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
Walkthrough
Toggle-all-expanded behavior now only marks rows as expanded when each row's getCanExpand returns true; other expanded-state branches and single-row expansion APIs remain unchanged. A changeset was added for a patch release describing this fix.
Changes
| Cohort / File(s) | Summary |
|---|---|
Row expansion logic packages/table-core/src/features/RowExpanding.ts |
When toggling all rows from a boolean true state, build the expanded map only including rows where getCanExpand(row) is true instead of marking every row as expanded; reset and single-row expansion behavior and public APIs preserved. |
Release metadata .changeset/every-parks-raise.md |
Adds a changeset entry for a patch release explaining the fix that prevents non-expandable rows from being added when the previous expanded state was true. |
Estimated code review effort
๐ฏ 3 (Moderate) | โฑ๏ธ ~20 minutes
- Review
getCanExpandinvocation and ensure it considers all relevant row collections (visible, flattened, virtualized). - Verify no regressions in reset/initial expanded-state handling.
- Confirm consumers of
onExpandedChangehandle sparse maps vs boolean consistently.
Poem
๐ฐ
I hopped through rows with careful pace,
I only fluffed the leaves that had the space,
No blanket spread where tunnels hide,
I marked just those that could open wide,
A tidy hop, a gentle trace. ๐ฟ
Pre-merge checks and finishing touches
โ Passed checks (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | โ Passed | The title clearly summarizes the main bug fix: preventing non-expandable rows from being included in the expanded state when it changes. |
| Description check | โ Passed | The description includes all required template sections with substantive content: detailed explanation of the issue and fix, completed checklist items, and confirmation of changeset generation. |
| Docstring Coverage | โ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
โจ Finishing touches
๐งช Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
๐ Recent review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
๐ฅ Commits
Reviewing files that changed from the base of the PR and between 9f7b4687e78467d4882ff0ce66df452b16052911 and 6ad1c8822213d8d13a04d18aa0760f32546df6da.
๐ Files selected for processing (1)
-
.changeset/every-parks-raise.md(1 hunks)
๐ง Files skipped from review as they are similar to previous changes (1)
- .changeset/every-parks-raise.md
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.
Comment @coderabbitai help to get the list of available commands and usage tips.
@coderabbitai help
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
-
I pushed a fix in commit <commit_id>, please review it. -
Open a follow-up GitHub issue for this discussion.
-
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. - PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:-
@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase. -
@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
-
CodeRabbit commands
These commands are invoked using PR/Issue comments.
-
@coderabbitai pauseto pause the reviews on a PR. -
@coderabbitai resumeto resume the paused reviews. -
@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository. -
@coderabbitai full reviewto do a full review from scratch and review all the files again. -
@coderabbitai summaryto regenerate the summary of the PR. -
@coderabbitai evaluate custom pre-merge check --instructions <custom-checks-instructions> --name <custom-checks-title> [--mode <error|warning>]to validate the custom pre-merge checks instructions. Defaults toerrorwhen--modeis omitted.-
@coderabbitai ignore pre-merge checksto override pre-merge checks and get an approval on PR. -
@coderabbitai run pre-merge checksto run pre-merge checks on the pull request.
-
-
@coderabbitai generate docstringsto generate docstrings for this PR. -
@coderabbitai generate sequence diagramto generate a sequence diagram of the changes in this PR. -
@coderabbitai generate unit teststo generate unit tests for this PR. -
@coderabbitai resolveto resolve all the CodeRabbit review comments. -
@coderabbitai configurationto show the current CodeRabbit configuration for the repository. -
@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreor@coderabbit ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit configuration file (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Status, support, documentation and community
- Visit our status page to check the current availability of CodeRabbit.
- Create a ticket on our support page for assistance with any issues or questions.
- Visit our documentation site for detailed information on how to use CodeRabbit.
- Join our Discord community to connect with other users and get help from the community.
- Follow us on X/Twitter for updates and announcements.
@coderabbitai full review
โ Actions performed
Full review triggered.
โ Actions performed
Review triggered.
Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.