feat(table-core): fix API to calculate max expanded row depth
๐ฏ 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.
๐ฆ 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
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.
Comment @coderabbitai help to get the list of available commands and usage tips.