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

Fix <FilterForm> applies but hides default value on clear #9182

Closed
wants to merge 1 commit into from

Conversation

fzaninotto
Copy link
Member

No description provided.

@@ -351,7 +351,7 @@ export const getQuery = ({
? queryFromLocation
: hasCustomParams(params)
? { ...params }
: { filter: filterDefaultValues || {} };
Copy link
Member Author

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 || {};
Copy link
Member Author

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,
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 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]) || '';
Copy link
Member Author

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

@fzaninotto
Copy link
Member Author

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.

@fzaninotto
Copy link
Member Author

Confirmed, this would be a breaking change, so I'm closing this PR.

@fzaninotto fzaninotto closed this Aug 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready For Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant