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

[data grid] Date Filter Issue with "before" Operator in @mui/x-data-grid-premium v6.0.0+ #11823

Closed
nguyenhoaikhang37 opened this issue Jan 26, 2024 · 1 comment
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! feature: Filtering Related to the data grid Filtering feature support: premium standard Support request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/

Comments

@nguyenhoaikhang37
Copy link

nguyenhoaikhang37 commented Jan 26, 2024

The problem in depth 🔍

Problem:

In versions 6.0.0 and later of @mui/x-data-grid-premium, it appears that there is a change in the buildApplyFilterFn() function related to handling date and numeric filters.

Issue Details:

In version 6.0.0, the following line has been removed:

const valueAsDate = value instanceof Date ? value : new Date(value.toString());
This removal leads to an issue when applying the date filter.

Unexpected Behavior:

In the buildApplyFilterFn() function, when using the "before" operator for the date filter, the keepHours parameter is passed as true. This causes the function to call getTime() on an ISO string (for date values), leading to an error and incorrect behavior.

Expected Behavior:

In version 5.17.26, the line:

const valueAsDate = value instanceof Date ? value : new Date(value.toString());

ensured that the date value is converted to new Date() before usage. Consider reintroducing this line or finding an alternative approach to ensure the correctness of date filters.

Steps to Reproduce:

Use version 6.0.0 or later of @mui/x-data-grid-premium.
Apply a date filter with the "before" operator.

Environment:

@mui/x-data-grid-premium Version: 6.16.2 or later.

Search keywords: filter issue with "before" Operator

@nguyenhoaikhang37 nguyenhoaikhang37 added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jan 26, 2024
@zannager zannager added component: data grid This is the name of the generic UI component, not the React module! support: premium standard Support request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/ labels Jan 26, 2024
@michelengelen
Copy link
Member

Hey @nguyenhoaikhang37 ... I cannot reproduce the issue with our demos.
Is there something specific that needs to be done for a reproduction?

Could you maybe create a mininmal example of the issue using this Stackblitz template. Thanks! 🙇🏼

@michelengelen michelengelen added bug 🐛 Something doesn't work status: waiting for author Issue with insufficient information feature: Filtering Related to the data grid Filtering feature and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jan 29, 2024
@michelengelen michelengelen changed the title Date Filter Issue with "before" Operator in @mui/x-data-grid-premium v6.0.0+ [data grid] Date Filter Issue with "before" Operator in @mui/x-data-grid-premium v6.0.0+ Jan 29, 2024
@github-actions github-actions bot removed the status: waiting for author Issue with insufficient information label Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! feature: Filtering Related to the data grid Filtering feature support: premium standard Support request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/
Projects
None yet
Development

No branches or pull requests

3 participants