-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Conversation
These are the results for the performance tests:
|
if (item.value === undefined) { | ||
deleteFilter(item); | ||
} else { | ||
// TODO v6: simplify the behavior by always removing the filter form |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// TODO v6: simplify the behavior by always removing the filter form | |
// TODO v6: simplify the behavior by always remove the filter form |
7c88838
to
37ac59c
Compare
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
@@ -243,7 +243,12 @@ function GridFilterForm(props: GridFilterFormProps) { | |||
|
|||
const handleDeleteFilter = () => { | |||
if (rootProps.disableMultipleColumnsFiltering) { | |||
applyFilterChanges({ ...item, value: undefined }); | |||
if (item.value === undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
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