Skip to content

fix(table-core): ensure getFilteredRowModel().flatRows uses pre-order traversal - #6568

Open
AbhiPra24 wants to merge 1 commit into
TanStack:mainfrom
AbhiPra24:fix/filtered-row-model-preorder-flatrows
Open

fix(table-core): ensure getFilteredRowModel().flatRows uses pre-order traversal#6568
AbhiPra24 wants to merge 1 commit into
TanStack:mainfrom
AbhiPra24:fix/filtered-row-model-preorder-flatrows

Conversation

@AbhiPra24

@AbhiPra24 AbhiPra24 commented Aug 21, 2026

Copy link
Copy Markdown

Fixes #6536

Summary

Aligns getFilteredRowModel().flatRows with pre-order depth-first traversal (matching the fix in #6529 for getSortedRowModel), ensuring parent rows precede their sub-rows in flatRows.

Verification

  • Unit tests added and passing in table-core.

Summary by CodeRabbit

  • Bug Fixes
    • Improved filtering for hierarchical table data.
    • Preserved parent-child row relationships and descendant indexes when filtering nested rows.
    • Ensured filtered row lists consistently follow pre-order traversal, with parents appearing before descendants.
    • Improved behavior for deeply nested data and partially filtered descendants.

@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9d004f71-0463-4c13-9183-3528c2c88571

📥 Commits

Reviewing files that changed from the base of the PR and between adfc6c5 and 8d25052.

📒 Files selected for processing (2)
  • packages/table-core/src/features/column-filtering/filterRowsUtils.ts
  • packages/table-core/tests/implementation/features/column-filtering/createFilteredRowModel.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

Filtering now produces flatRows in depth-first pre-order for leaf-first and root-first filtering. The implementation updates row construction and indexing. Tests cover nested hierarchies, retained descendants, and depth-limited filtering.

Changes

Filtered row ordering

Layer / File(s) Summary
Filtered row construction
packages/table-core/src/features/column-filtering/filterRowsUtils.ts
Leaf-first and root-first filtering construct retained rows before registering descendants and indexes. Depth-limited filtering preserves descendant indexes.
Pre-order flattening tests
packages/table-core/tests/implementation/features/column-filtering/createFilteredRowModel.test.ts
Tests assert parent-before-descendant flatRows ordering for leaf filtering, root filtering, nested data, and depth-limited filtering.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 8d250

This localized change aligns filtered row ordering with the intended pre-order traversal and includes unit tests; no actionable merge-blocking risk remains beyond normal checks and review.

Suggested reviewers: kevinvandy

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ 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%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the fix to pre-order traversal in getFilteredRowModel().flatRows.
Description check ✅ Passed The description explains the change and verification, but it omits the repository checklist and release impact sections.
Linked Issues check ✅ Passed The implementation and tests address issue #6536 by enforcing parent-first flatRows ordering for both filtering paths.
Out of Scope Changes check ✅ Passed The source and test changes are limited to the linked issue's filtering order fix and its required coverage.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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.

getFilteredRowModel().flatRows is post-order, same bug #6529 just fixed for getSortedRowModel

1 participant