Skip to content

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

Closed

Description

@marceloverdijk

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

  • 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.

Activity

  1. marceloverdijk commented on Aug 1, 2022

    @marceloverdijk
    ContributorAuthor

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

  2. changed the title [-][v8] Filter not working if accessorFn return null for any row[/-] [+][v8] Filter not working if accessorFn returns null for any row[/+] on Aug 2, 2022
  3. simPod commented on Sep 9, 2022

    @simPod

    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.

  4. KevinVandy commented on Nov 14, 2022

    @KevinVandy
    Member

    Fixed by #4441

  5. axeldvp commented on Jun 16, 2023

    @axeldvp

    Hello, even with this fix :

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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