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

[DataGrid] Fix cell value type in quick filtering v7 #10884

Merged

Conversation

cherniavskii
Copy link
Member

Reverts c14f23c from #10569
I thought this was an optimization, but it turned out to cause issues with non-string column types.
E.g. for the date column type, value is supposed to be of type Date, while it currently is string (because value formatter returns string).

I have discovered this issue while working on #10581

@cherniavskii cherniavskii added component: data grid This is the name of the generic UI component, not the React module! regression A bug, but worse feature: Filtering Related to the data grid Filtering feature labels Nov 3, 2023
@mui-bot
Copy link

mui-bot commented Nov 3, 2023

Deploy preview: https://deploy-preview-10884--material-ui-x.netlify.app/

Generated by 🚫 dangerJS against decaba4

@cherniavskii cherniavskii force-pushed the fix-cellValue-type-in-quick-filter-v7 branch from ecdef46 to 456018f Compare November 3, 2023 11:57
@@ -220,7 +221,7 @@ const getFilterCallbackFromItem = (
if (ignoreDiacritics) {
value = removeDiacritics(value);
}
return applyFilterOnRow(value, row, column, apiRef);
return applyFilterOnRow(value, row, column, getPublicApiRef(apiRef));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We were passing private apiRef here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, nice catch 👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we create the API ref outside this function? I think this one is inside the filter loop, so we're doing O(n) allocations if we call getPublicApiRef here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment applies below, line 420.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching it, updated it!

Comment on lines +17 to +20
let columnValue = apiRef.current.getRowFormattedValue(row, column);
if (apiRef.current.ignoreDiacritics) {
columnValue = removeDiacritics(columnValue);
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a disadvantage compared to v6 filtering, where it was possible to overwrite the cellParams.formattedValue.

@cherniavskii cherniavskii merged commit 94f09ed into mui:master Nov 6, 2023
5 checks passed
@cherniavskii cherniavskii deleted the fix-cellValue-type-in-quick-filter-v7 branch November 6, 2023 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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 regression A bug, but worse
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants