-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Description
TanStack Table version
v9.0.0-alpha.19
Framework/Library version
v19.2.4
Describe the bug and the steps to reproduce it
The four comparison filter functions (filterFn_greaterThan, filterFn_greaterThanOrEqualTo, filterFn_lessThan, filterFn_lessThanOrEqualTo) incorrectly have .resolveFilterValue set to testFalsy(). They should use
.autoRemove instead, matching every other simple filter function in the file.
Root cause in packages/table-core/src/fns/filterFns.ts (lines 144, 163, 179, 195):
filterFn_greaterThan.resolveFilterValue = (val: any) => testFalsy(val)
// Same for greaterThanOrEqualTo, lessThan, lessThanOrEqualTo
resolveFilterValue transforms the filter value before comparison (createFilteredRowModel.ts:81):
resolvedValue: filterFn.resolveFilterValue?.(columnFilter.value) ?? columnFilter.value
When a user sets a filter like "price > 50":
- resolveFilterValue(50) calls testFalsy(50) → returns false
- The resolved value becomes false ?? 50 → false (because false is not nullish)
- The comparison becomes rowValue > false, which JS coerces to rowValue > 0
- Every non-zero row passes the filter instead of only rows > 50
Additionally, these 4 functions are missing .autoRemove entirely, so filters with empty values (undefined, null, '') are never auto-removed.
Steps to reproduce:
- Create a table with a numeric column using filterFn: filterFn_greaterThan
- Set a column filter: table.setColumnFilters([{ id: 'price', value: 50 }])
- Expected: Only rows with price > 50 are shown
- Actual: All rows with price > 0 are shown
Your Minimal, Reproducible Example - (Sandbox Highly Recommended)
None
Screenshots or Videos (Optional)
No response
Do you intend to try to help solve this bug with your own PR?
Yes, I am also opening a PR that solves the problem along side this issue
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.