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 some filters being removed from filter model on filter panel open #5403

Conversation

cherniavskii
Copy link
Member

@cherniavskii cherniavskii commented Jul 5, 2022

@cherniavskii cherniavskii added 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 labels Jul 5, 2022
@mui-bot
Copy link

mui-bot commented Jul 5, 2022

These are the results for the performance tests:

Test case Unit Min Max Median Mean σ
Filter 100k rows ms 259.8 581.7 404.4 388.46 113.201
Sort 100k rows ms 478.3 1,011.8 675.6 766.74 183.696
Select 100k rows ms 127 200.7 189 174.3 27.844
Deselect 100k rows ms 94 262.5 262.5 186.12 75.653

Generated by 🚫 dangerJS against d2611b0

@cherniavskii cherniavskii force-pushed the fix-isEmpty-filter-removed-from-filter-panel branch from abc52ff to dab4975 Compare July 5, 2022 18:50
Copy link
Member

@alexfauquette alexfauquette left a comment

Choose a reason for hiding this comment

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

Nice fix

Relying on th existence of a component to know is the filter is active when item.value===undefined seems flaky but I do not have other solutions

Copy link
Member

@flaviendelangle flaviendelangle left a comment

Choose a reason for hiding this comment

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

An alternative would be to create a new optional property on GridFilterOperator named hasValue?: (item: GridFilterItem) => boolean with a default value being hasValue: item => item !== undefined

It would work on weird edge cases (for instance if a user creates a custom panel and rely on the name of the operator to display a component instead of InputComponent, that's not how it should be used so maybe having it break is not that problematic).

Copy link
Member

@m4theushw m4theushw left a comment

Choose a reason for hiding this comment

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

Do you want to merge this to include in the release?

@cherniavskii
Copy link
Member Author

Do you want to merge this to include in the release?

No, there might be some room for improvement as pointed out by Flavien

@cherniavskii
Copy link
Member Author

An alternative would be to create a new optional property on GridFilterOperator named hasValue?: (item: GridFilterItem) => boolean with a default value being hasValue: item => item !== undefined

Thanks @flaviendelangle
I've used a slightly different signature: requiresFilterValue?: boolean to simplify things. It's better than just checking InputComponent 👍

@cherniavskii cherniavskii force-pushed the fix-isEmpty-filter-removed-from-filter-panel branch from dab4975 to fd45d7e Compare July 15, 2022 15:09
@cherniavskii cherniavskii force-pushed the fix-isEmpty-filter-removed-from-filter-panel branch from fd45d7e to d2611b0 Compare July 15, 2022 20:41
@cherniavskii cherniavskii merged commit 746be79 into mui:master Jul 15, 2022
@cherniavskii cherniavskii deleted the fix-isEmpty-filter-removed-from-filter-panel branch July 15, 2022 21:03
@cherniavskii cherniavskii mentioned this pull request Jul 15, 2022
alexfauquette pushed a commit to alexfauquette/mui-x that referenced this pull request Aug 26, 2022
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DataGrid] Filter state is not persistent when using "is empty" and "is not empty" operators
5 participants