-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Description
TanStack Table version
v8.21.3
Framework/Library version
React v18.3.1
Describe the bug and the steps to reproduce it
Overview
If the filterFromLeafRows
config option is true
, columnFiltersMeta
gets wiped from each row when the row model gets built. This happens even when there are no leaf rows (AKA subRows
). A helper used to build the row model replaces each row with a copy, but neglects to copy this particular attribute over from the old one.
My use case for columnFiltersMeta
is essentially identical to the one demonstrated in the Filters Fuzzy example (sorting based on a rank score which is calculated during filtering and stored in columnFiltersMeta
).
Expected behavior
My opinion is that each row's columnFiltersMeta
should remain as-is amidst whatever else gets done during leaf-row filtering logic. The convenient behavior in my particular case would be for sub rows' search rankings to somehow get aggregated into the parent's value (e.g. take the max rank among parent and all sub rows). That would be analogous to the main point of filterFromLeafRows
, which is that sub rows passing the filter cause parent rows to also pass. However, the thing that consumes columnFiltersMeta
in my case (column sortingFn
) has access to row.subRows
directly anyway. I would support a new convenience feature for this specific filter/rank use case, but I don't see a need to bake any part of it into the generic columnFiltersMeta
feature.
My hoped-for fix would be that columnFiltersMeta
simply gets copied into the new row alongside other things that are already correctly copied (e.g. columnFilters
).
Repro
Forked from React Example: Filters Fuzzy, with one line added: filterFromLeafRows: true
in the table config.
Your Minimal, Reproducible Example - (Sandbox Highly Recommended)
https://stackblitz.com/edit/tanstack-table-uy4nphk2?file=src%2Fmain.tsx
Screenshots or Videos (Optional)
No response
Do you intend to try to help solve this bug with your own PR?
Maybe, I'll investigate and start debugging
Terms & Code of Conduct
- I agree to follow this project's Code of Conduct
- I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.