Skip to content

Column Filtering does not work when using the column accessorFn to manipulate a boolean field. #4951

@changyeamoon

Description

@changyeamoon

Describe the bug

When you have a boolean field in your dataset that you feed to the table and you want to filter on that boolean field by changing its value to a String (e.g !!status ? 'Active' : 'Inactive') then when you try to filter on them, it doesn't filter correctly.

I think the reproducible steps give a clearer explanation

Your minimal, reproducible example

https://codesandbox.io/p/sandbox/accessorkey-filter-q7534z?embed=1&file=%2Fsrc%2Fmain.tsx%3A7%2C10

Steps to reproduce

GIVEN I set up data that has a boolean field in it (e.g status)
AND I set up the table (using an example from the docs (filter example))
AND I use the accessorFn field on the columnDef to manipulate the boolean (e.g !!status ? 'Active' : 'Inactive')
AND filtering is enabled
WHEN I select the status filter and select 'Active'
THEN the columns do not filter correctly. You still see some 'Inactive' rows

Expected behavior

Same as steps to reproduce but with ->

THEN the columns do filter correctly.

How often does this bug happen?

Every time

Screenshots or Videos

Screen.Recording.2023-07-06.at.12.26.38.AM.mov

Platform

macOS, Google Chrome latest

react-table version

8.9.3

TypeScript version

4.9.5

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