table icon indicating copy to clipboard operation
table copied to clipboard

Numeric column's automatic filter autoremove interferes with manual filtering

Open Faithfinder opened this issue 11 months ago • 1 comments

TanStack Table version

8.20.6

Framework/Library version

18.3.0

Describe the bug and the steps to reproduce it

I'd like to implement filters with different operators for columns (e.g., a user can choose whether they want greater than or less than for numeric, for example). I'd also like to do filtering server side.

When I define a minimal column definition, the automatic filtering kicks in. Even with manualFilter turned on, autoremove logic still plays out.

For numeric columns, it treats an object as falsy due to (testFalsey(val[0]) && testFalsey(val[1]) condition.

There's a billion possible workarounds, but IMO the fix is to check whether val is an array first. This would still give bad results if somebody uses an array as filter value, but that use case is harder to imagine

Your Minimal, Reproducible Example - (Sandbox Highly Recommended)

https://stackblitz.com/edit/tanstack-table-8erjbq2f?file=src%2Fmain.tsx

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

  • [x] I agree to follow this project's Code of Conduct
  • [x] 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.

Faithfinder avatar Feb 05 '25 02:02 Faithfinder

I found the same issue. When manualFiltering is true, the autoRemove function should not even be called. I am using server-side filters, but onColumnFiltersChange was not triggered because the autoRemove function returned false. I added filterFn: () => true to defaultColumn to make sure any filter triggers my custom filter function.

gidomanders avatar Sep 02 '25 12:09 gidomanders