Skip to content

Error when global filter called for numeric columns #4210

@lexanth

Description

@lexanth

Describe the bug

#4124 (fixed by a5578ac) makes the table now call the global filter functions for strings and numbers.

However, most of the built-in filter functions don't handle numbers, they assume the value is a string (https://github.com/TanStack/table/blob/main/packages/table-core/src/filterFns.ts)

This makes it very liable to break (e.g. auto filter does includesString, which breaks on toLowerCase). The workaround is easy - provide a custom filter function for numeric columns or exclude them from the filtering.

It would be nicer if the default filter functions handled numbers

Your minimal, reproducible example

https://nyxdj8.sse.codesandbox.io

Steps to reproduce

  1. Type "a" in the global filter
  2. See Uncaught TypeError: _row$getValue.toLowerCase is not a function in the console (filtering doesn't complete)

Expected behavior

The default filter functions should handle numbers by default

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

macOS, Chrome

react-table version

8.3.0

TypeScript version

4.6.3

Additional context

No response

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