table icon indicating copy to clipboard operation
table copied to clipboard

feat(table-core): fix API to calculate max expanded row depth

Open ugjjffu opened this issue 2 months ago โ€ข 2 comments

๐ŸŽฏ Changes

I fixed a logic bug in the toggleExpanded function that led to an incorrect calculation of tableDepth. The original logic only deleted the expanded row's ID, but it failed to recursively delete the IDs of its hidden child rows. I fixed this bug by implementing a recursive deletion mechanism to ensure all dependent child rows are correctly removed from the expanded 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

Release Notes

  • Bug Fixes

    • Improved row collapsing behavior. When you collapse an expanded row, the row and all its nested descendant rows are now properly removed from the expanded state while preserving other rows' states.
  • Breaking Changes

    • Major version update includes a fix to how the maximum depth of expanded rows is calculated.

ugjjffu avatar Oct 24 '25 12:10 ugjjffu

๐Ÿฆ‹ Changeset detected

Latest commit: 5c43c9c277b23370b79252d5bbe4242eb41bbdc8

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 Major
@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 24 '25 12:10 changeset-bot[bot]

Walkthrough

The row expansion feature now removes collapsed rows and their entire descendant hierarchy from the expanded state, rather than just removing the single row entry. This ensures complete cleanup of nested expanded rows when a parent row is collapsed.

Changes

Cohort / File(s) Summary
Row Expansion Logic
packages/table-core/src/features/RowExpanding.ts
Modified collapse behavior to filter out all keys starting with the current row's id, removing the row and all its descendants from expanded state instead of single-key removal
Changeset Entry
.changeset/every-grapes-judge.md
Added changeset documenting major version bump for @tanstack/table-core with API fix for calculating maximum depth of expanded rows

Estimated code review effort

๐ŸŽฏ 2 (Simple) | โฑ๏ธ ~10 minutes

Poem

Down the tree of rows so wide,
Collapse the branch, its children hide,
No orphans left to expand in vain,
Clean state reigns, descendants wane! ๐Ÿฐโœจ

Pre-merge checks and finishing touches

โŒ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage โš ๏ธ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
โœ… Passed checks (2 passed)
Check name Status Explanation
Title Check โœ… Passed The PR title "feat(table-core): fix API to calculate max expanded row depth" is directly related to the main change in the pull request. The changeset and code modifications address a bug in the toggleExpanded function where collapsing a row now correctly removes the expanded state for that row and all its descendants by filtering keys that start with the row's id, rather than just removing a single entry. This fix ensures the tableDepth calculation becomes accurate, which is exactly what the title references. The title is concise, specific enough for scanning history, and accurately captures the intent of the fix.
Description Check โœ… Passed The PR description follows the required template structure with all three sections present and appropriately filled. The ๐ŸŽฏ Changes section clearly explains the bug in toggleExpanded and describes the recursive deletion fix implemented to resolve the tableDepth calculation issue. The โœ… Checklist section confirms both contributing guide compliance and local testing were completed. The ๐Ÿš€ Release Impact section indicates the change affects published code and a changeset was generated. All required information is provided with sufficient detail.
โœจ 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 207f890b99fdcdca8d47814c6ea97ad11cade9d3 and 5c43c9c277b23370b79252d5bbe4242eb41bbdc8.

๐Ÿ“’ Files selected for processing (1)
  • .changeset/every-grapes-judge.md (1 hunks)
๐Ÿ”‡ Additional comments (1)
.changeset/every-grapes-judge.md (1)

1-5: Verify the changeset description and version bump level.

The description "fix API to calculate max expanded row depth" could be more specific. Based on the PR context, the actual fix involves recursively removing descendant row IDs from the expanded state when collapsing a parent row (previously only the parent was removed).

Additionally, the "major" version bump should be verified as appropriate for this change. While this fixes a logic bug with a behavioral impact, confirm whether this is truly a breaking API change that warrants a major version.


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 24 '25 12:10 coderabbitai[bot]