-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Fix <FilterForm>
applies but hides default value on clear
#9182
Conversation
@@ -351,7 +351,7 @@ export const getQuery = ({ | |||
? queryFromLocation | |||
: hasCustomParams(params) | |||
? { ...params } | |||
: { filter: filterDefaultValues || {} }; |
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.
here, we applied filter default values only if there were no saved params. This prevented default values to be applied when a user resets all filters (because if they saved the filters once, they have some params in the store containing the sort and pagination)
@@ -364,6 +364,10 @@ export const getQuery = ({ | |||
query.page = 1; | |||
} | |||
|
|||
if (!query.filter || Object.keys(query.filter).length === 0) { | |||
query.filter = filterDefaultValues || {}; |
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.
now we use filterdefaultValues even if there are some params - but only if the filter params is empty.
@@ -161,6 +161,7 @@ const sanitizeRestProps = ({ | |||
displayedFilters, | |||
filterValues, | |||
hasCreate, | |||
showFilter, |
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.
This was causing warnings in tests
@@ -250,7 +251,7 @@ const getInputValue = ( | |||
filterValues: Record<string, any> | |||
) => { | |||
if (formValues[key] === undefined || formValues[key] === null) { | |||
return ''; | |||
return (filterValues && filterValues[key]) || ''; |
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.
default to the filterValues from the URL when they change
So this conflicts with another feature, which allows user to remove filters with default values (see #2831). I suspect we can't have both features. Investigating. |
Confirmed, this would be a breaking change, so I'm closing this PR. |
No description provided.