Skip to content

filterFn_greaterThan (and 3 related fns) use .resolveFilterValue instead of .autoRemove, corrupting filter comparisons #6212

@rkdfx

Description

@rkdfx

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":

  1. resolveFilterValue(50) calls testFalsy(50) → returns false
  2. The resolved value becomes false ?? 50 → false (because false is not nullish)
  3. The comparison becomes rowValue > false, which JS coerces to rowValue > 0
  4. 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:

  1. Create a table with a numeric column using filterFn: filterFn_greaterThan
  2. Set a column filter: table.setColumnFilters([{ id: 'price', value: 50 }])
  3. Expected: Only rows with price > 50 are shown
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions