Skip to content

Date-range/custom filterVariant does not work with a correctly setup accessorFn #489

@17as

Description

@17as

mantine-react-table version

2.0.0-beta.6

react & react-dom versions

18.2.0

Describe the bug and the steps to reproduce it

I tried to implement a date-range filter variant for dateOfBirth. I am using date from a rest api fetched using @tanstack/react-query library.

If I setup the accessorFn like below, filter functionality works fine, but in the table cell where the date of birth should be displayed no date is shown
accessorFn: (originalRow: { applicant: { dateOfBirth: string | number | Date }; }) => { const date = new Date(originalRow?.user?.dateOfBirth); !isNaN(date.getTime()) ? date.toISOString() : ""; },

Otherwise, is I setup accessorFn the correctly with a return statement
accessorFn: (originalRow: { applicant: { dateOfBirth: string | number | Date }; }) => { const date = new Date(originalRow?.user?.dateOfBirth); return !isNaN(date.getTime()) ? date.toISOString() : ""; },

table cell displays the correct date of birth but the date-range filter does not work anymore. The table displays absolutely no rows, but the date is passed correctly to the table (for example pagination calculates correctly the number of pages when the filter values are changed, but the table shows 0 rows).

I also tried filterVariant: "custom" but with the very same behaviour: works with the accessorFn setup like in the first example, does not works when accessorFn has a return statement.

Minimal, Reproducible Example - (Optional, but Recommended)

n/a

Screenshots or Videos (Optional)

No response

Do you intend to try to help solve this bug with your own PR?

None

Terms

  • I understand that if my bug cannot be reliably 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

    V2Issue with MRT V2bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions