-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Description
TanStack Table version
v8.21.3
Framework/Library version
Vue 3.5.21
Describe the bug and the steps to reproduce it
I have the following column:
columnHelper.accessor('foo', {
filterFn: (() => {
const filterFn = (row, columnId, filterValue) => {
return filterValue === row.getValue(columnId)
}
filterFn.autoRemove = val => val === undefined
return filterFn
})(),
})
I use filterFn.autoRemove = val => val === undefined
in order to only remove the filter if the value is undefined
.
The provided autoRemove
function is however ignored if I do column.setFilterValue('')
and the filter array remains empty.
Here is the code causing this:
table/packages/table-core/src/features/ColumnFiltering.ts
Lines 423 to 427 in 02c203a
(filterFn && filterFn.autoRemove | |
? filterFn.autoRemove(value, column) | |
: false) || | |
typeof value === 'undefined' || | |
(typeof value === 'string' && !value) |
I would expect the function I provide to take precedence, because otherwise there is no way to filter for empty strings. All build in filter functions have code like testFalsey(val)
so a change would not impact the current behavior of the build in functions.
I would even go as for and remove the check for typeof value === 'undefined'
if a custom function is provided.
Your Minimal, Reproducible Example - (Sandbox Highly Recommended)
No response
Screenshots or Videos (Optional)
No response
Do you intend to try to help solve this bug with your own PR?
Yes, I think I know how to fix it and will discuss it in the comments of 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.