table icon indicating copy to clipboard operation
table copied to clipboard

[BUG] ignore non expandable rows when the expanded state changes

Open RichardHpa opened this issue 3 months ago โ€ข 7 comments

๐ŸŽฏ 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.

RichardHpa avatar Oct 21 '25 01:10 RichardHpa

๐Ÿฆ‹ 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

changeset-bot[bot] avatar Oct 21 '25 01:10 changeset-bot[bot]

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 getCanExpand invocation and ensure it considers all relevant row collections (visible, flattened, virtualized).
  • Verify no regressions in reset/initial expanded-state handling.
  • Confirm consumers of onExpandedChange handle 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.

โค๏ธ Share

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

coderabbitai[bot] avatar Oct 21 '25 01:10 coderabbitai[bot]

@coderabbitai help

RichardHpa avatar Oct 21 '25 01:10 RichardHpa

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 @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in 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 pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to 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 to error when --mode is omitted.
    • @coderabbitai ignore pre-merge checks to override pre-merge checks and get an approval on PR.
    • @coderabbitai run pre-merge checks to run pre-merge checks on the pull request.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit configuration file (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file 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[bot] avatar Oct 21 '25 01:10 coderabbitai[bot]

@coderabbitai full review

RichardHpa avatar Oct 21 '25 01:10 RichardHpa

โœ… Actions performed

Full review triggered.

coderabbitai[bot] avatar Oct 21 '25 01:10 coderabbitai[bot]

โœ… 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.

coderabbitai[bot] avatar Oct 21 '25 01:10 coderabbitai[bot]