Uh oh!
There was an error while loading. Please reload this page.
fix(column-filtering): include sub-rows in flatRows when maxLeafRowFilterDepth skips recursion - #6395
Conversation
…lterDepth skips recursion `filterRowModelFromRoot` was discarding sub-rows when the parent passed the filter but `depth >= maxLeafRowFilterDepth`. The parent row got pushed into `flatRows` and `rowsById`, but the children stayed reachable only via `row.subRows`, leaving `flatRows` an incomplete view of the visible tree. `column.getFacetedUniqueValues()` (which iterates `flatRows`) returned consistent counts before filtering but inconsistent counts after, because the pre-filter `flatRows` from the core row model includes sub-rows while the filtered `flatRows` did not. Add a small helper `addSubRowsToFlatArrays` that recursively pushes each surviving sub-row into `flatRows` and `rowsById`, and call it from the `else if` branch the parent-pass / depth-skipped case falls into. The branch is reached only when `row.subRows.length` is truthy, so the helper always has work to do. ClosesTanStack#6361 (refs TanStack#5987)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds a recursive helper ChangesflatRows Consistency Fix
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Fixes#6361 (refs #5987).
Bug
`filterRowModelFromRoot` discarded sub-rows when the parent passed the filter but recursion was skipped because `depth >= maxLeafRowFilterDepth`. The parent row was pushed into `flatRows` and `rowsById`, but the children stayed reachable only via `row.subRows`, leaving `flatRows` an incomplete view of the visible tree.
`column.getFacetedUniqueValues()` (which iterates `flatRows`) returned consistent counts before filtering but inconsistent counts after, because the pre-filter `flatRows` from the core row model includes sub-rows while the filtered `flatRows` did not.
Fix
Add a small helper `addSubRowsToFlatArrays` that recursively pushes each surviving sub-row into `flatRows` and `rowsById`, and call it from the `else if` branch the parent-pass / depth-skipped case falls into. The branch is reached only when `row.subRows.length` is truthy, so the helper always has work to do.
`flatRows` and `rowsById` now contain the same set of rows that `rows` plus the surviving `row.subRows` paths cover, so faceted-unique counts and other flat-row consumers agree with the visible tree.
`filterRowModelFromLeafs` already pushed every passing leaf (including sub-rows that came from recursion) into `flatRows` via its own loop, so the bug was specific to `filterRowModelFromRoot`.
Tests
Local test harness is not available in this environment (no `node_modules`), but the change is small and the cases are mechanical:
A follow-up commit can add a regression test once the test harness is wired up locally; happy to do that in response to review feedback.
1 file changed, +20/-0.
Summary by CodeRabbit