table icon indicating copy to clipboard operation
table copied to clipboard

[v8] Filter not working if accessorFn returns null for any row

Open marceloverdijk opened this issue 3 years ago • 2 comments

Describe the bug

Filtering a column defines like:

{
        id: 'name',
        header: 'Name',
        accessorKey: 'name',
}

works, even if that column has null values.

Now when doing

{
        id: 'name',
        header: 'Name',
        accessorFn: (row) => row.name !== 'ignore' ? row.name : null,
}

in this case filtering does not work anymore at all. So even not for the rows returning a value.

I can use this workaround:

{
        id: 'name',
        header: 'Name',
        accessorFn: (row) => row.name !== 'ignore' ? row.name : '',
}

but this should not be needed I would say.

Your minimal, reproducible example

Steps to reproduce

See above.

Expected behavior

Rows with actual value to be filtered succesfully.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

macOS

react-table version

v8.5.1, v.8.5.2

TypeScript version

v4.7.4

Additional context

No response

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.

marceloverdijk avatar Aug 01 '22 11:08 marceloverdijk

Another issue with the workaround mentioned (return '') is that sortUndefined: 1, won't work anymore.

marceloverdijk avatar Aug 01 '22 12:08 marceloverdijk

I stumbled upon this as well. I went to check the tests to see what the correct behaviour is but there are no tests :/ I'm trying to find out where the exception for null is.

simPod avatar Sep 09 '22 11:09 simPod

Fixed by #4441

KevinVandy avatar Nov 14 '22 02:11 KevinVandy

Hello, even with this fix :

If the 1st value is null, globalFilter doesn't work.

axeldvp avatar Jun 16 '23 10:06 axeldvp