[data grid] Date Filter Issue with "before" Operator in @mui/x-data-grid-premium v6.0.0+ #11823
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/
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 thebuildApplyFilterFn()
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
The text was updated successfully, but these errors were encountered: