Skip to content

Conversation

RichardHpa
Copy link

@RichardHpa RichardHpa commented Oct 21, 2025

🎯 Changes

Resolving the issue I bought up in #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

  • 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 the "expand all" toggle so it only expands rows that are eligible for expansion. Toggling now preserves single-row expansion behavior and external change handlers, and avoids marking non-expandable rows as expanded. This prevents unintended visual/state changes when using the expand-all control and improves table reliability and consistency.

Copy link

changeset-bot bot commented Oct 21, 2025

🦋 Changeset detected

Latest commit: 35541e2

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

Copy link

coderabbitai bot commented Oct 21, 2025

Walkthrough

RowExpanding now filters rows by their canExpand capability when toggling all-expanded; only rows that can expand are marked expanded. Other expanded-state handling and single-row expansion logic remain unchanged.

Changes

Cohort / File(s) Summary
Row expansion logic fixes
packages/table-core/src/features/RowExpanding.ts
When toggling all rows to expanded, only set rows as expanded if getCanExpand returns true for that row; preserved existing mapping to onExpandedChange and single-row logic.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant T as Table UI
    participant R as RowExpanding
    participant S as ExpandedState

    U->>T: click "toggle all expanded"
    T->>R: toggleAllRowsExpanded(old = true)
    alt old === true
        R->>R: iterate visible row IDs
        loop per row
            R->>R: call getCanExpand(rowId)
            alt canExpand == true
                R->>S: mark rowId as expanded (oldExpanded[rowId] = true)
            else canExpand == false
                R-->>S: skip rowId
            end
        end
    else old === false
        R->>S: clear expanded state (unchanged behavior)
    end
    R->>T: call onExpandedChange(mapped setExpanded)
    T->>U: UI updates accordingly
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰
I hopped through rows with careful pace,
Only fluffed the ones that had the space,
No blanket spread across the ground,
Just proper hops where canExpand is found. 🌿

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title "[BUG] ignore non expandable rows when the expanded state changes" directly describes the main change in the codebase. According to the raw summary, the modification adds a check to ensure rows are expandable (via canExpand validation) before including them in the expanded state when toggling with old === true, which previously unconditionally set all row IDs. The title accurately and concisely captures this core fix and its purpose. The title is specific, clear, and helps anyone scanning the repository history understand the primary change.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
Description Check ✅ Passed The pull request description follows the required template structure completely, including all three main sections: 🎯 Changes, ✅ Checklist, and 🚀 Release Impact. The Changes section provides clear context by referencing the original issue (#6115), explaining the problem (non-expandable rows being included in expanded state), and describing the solution (adding a check for expandability). Both critical checklist items are marked as completed, indicating the contributor followed the Contributing guide and ran local tests. The Release Impact section is properly filled out, indicating this affects published code with a changeset generated.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/table-core/src/features/RowExpanding.ts (1)

211-213: Revert unnecessary stylistic change.

The block statement with explicit return is functionally identical to the concise arrow body. Since setExpanded returns void, consider reverting to the more concise form for consistency:

-table.setExpanded = updater => {
-  return table.options.onExpandedChange?.(updater)
-}
+table.setExpanded = updater => table.options.onExpandedChange?.(updater)
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 02c203a and c5f80b7.

📒 Files selected for processing (1)
  • packages/table-core/src/features/RowExpanding.ts (2 hunks)
🔇 Additional comments (1)
packages/table-core/src/features/RowExpanding.ts (1)

299-304: Good fix! Verify existing tests cover this scenario.

This correctly filters out non-expandable rows when converting from expanded: true to an explicit object state. Previously, all rows were marked as expanded regardless of their canExpand() status, which could lead to inconsistent state.

Please verify that this change is covered by tests:

@RichardHpa RichardHpa changed the title dont include rows that arent expandable [BUG] ignore non expandable rows when the expanded state changes Oct 21, 2025
@RichardHpa
Copy link
Author

@coderabbitai help

Copy link

coderabbitai bot commented Oct 21, 2025

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.

@RichardHpa
Copy link
Author

@coderabbitai full review

Copy link

coderabbitai bot commented Oct 21, 2025

✅ Actions performed

Full review triggered.

Copy link

coderabbitai bot commented Oct 21, 2025

✅ 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.

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