Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 task done
17as opened this issue Feb 12, 2025 · 1 comment
Open
1 task done

Comments

@17as
Copy link

17as commented Feb 12, 2025

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.
@redvelvet511
Copy link

Hi! I am also experiencing the same issue. Have you possibly found a workaround it? I'm still trying to find a solution.. @17as

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants