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] Remove last filter item when no value to clean and close the filter panel #3910

Merged
merged 5 commits into from
Feb 21, 2022

Conversation

alexfauquette
Copy link
Member

Fix #3841

It modifies the behavior of the filter pannel by closing it when deleting the last item. But I see that as an improvement instead of a breaking change

@mui-bot
Copy link

mui-bot commented Feb 10, 2022

These are the results for the performance tests:

Test case Unit Min Max Median Mean σ
Filter 100k rows ms 243.8 402.8 297.1 310.02 55.893
Sort 100k rows ms 413.3 1,035.9 673.7 770.36 214.823
Select 100k rows ms 190.7 295.7 211.3 223.24 37.824
Deselect 100k rows ms 95.1 155.4 155.4 114.54 21.696

Generated by 🚫 dangerJS against 40c00cd

if (item.value === undefined) {
deleteFilter(item);
} else {
// TODO v6: simplify the behavior by always removing the filter form
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// TODO v6: simplify the behavior by always removing the filter form
// TODO v6: simplify the behavior by always remove the filter form

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Feb 17, 2022
@github-actions
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Feb 21, 2022
@alexfauquette alexfauquette added 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 Feb 21, 2022
@alexfauquette alexfauquette merged commit b762282 into mui:master Feb 21, 2022
@alexfauquette alexfauquette deleted the cleanFilterPanel branch February 21, 2022 09:07
@@ -243,7 +243,12 @@ function GridFilterForm(props: GridFilterFormProps) {

const handleDeleteFilter = () => {
if (rootProps.disableMultipleColumnsFiltering) {
applyFilterChanges({ ...item, value: undefined });
if (item.value === undefined) {
Copy link
Member

@m4theushw m4theushw Feb 21, 2022

Choose a reason for hiding this comment

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

Note that it only deletes the last item when clicking twice. In a string column, the empty input means item.value="" which falls into the else branch.

msedge_dvGxFA5EbL

Copy link
Member Author

Choose a reason for hiding this comment

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

And I assume the isAnyOf after being cleaned is an empty array, so we have two more cases to check, but we can not use !item.value due to boolean filters

apiRef.current.deleteFilterItem(item);
if (shouldCloseFilterPanel) {
apiRef.current.hideFilterPanel();
Copy link
Member

Choose a reason for hiding this comment

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

If the developer is controlling the filter items through the filterModel prop we don't know if he accept the new value passed via onFilterModelChange. In this case we can't assume that when hideFilterPanel is called it will have 0 filter items. I had the same problem with the editRowsModel prop triggering synchronous actions after changing the prop value.

Copy link
Member Author

Choose a reason for hiding this comment

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

I forget it was controllable. We could track items.length and close the pannel when reaching 0

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot clear filters in MUI Datagrid
5 participants