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 hideFilter called repeatedly only registers the last call #6226

Merged
merged 3 commits into from
Apr 30, 2021

Conversation

fzaninotto
Copy link
Member

Closes #6055

@fzaninotto fzaninotto added the RFR Ready For Review label Apr 29, 2021
@@ -229,38 +240,18 @@ const useListParams = ({
);

const hideFilter = useCallback((filterName: string) => {
// we don't use lodash.set() for displayed filters
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 moved the logic to the queryReducer for easier testability, but that has no effect on the bug.

});
}, requestSignature); // eslint-disable-line react-hooks/exhaustive-deps

const showFilter = useCallback((filterName: string, defaultValue: any) => {
// we don't use lodash.set() for displayed filters
Copy link
Member Author

Choose a reason for hiding this comment

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

Same, this change is just cosmetic

@@ -163,21 +164,31 @@ const useListParams = ({
}, []); // eslint-disable-line

const changeParams = useCallback(action => {
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 is the fix: since changeParams can be called several times in the same tick, we keep the result if the reducer locally so that we can start from it if another call comes immediately after. And we change the location (or the local state) only at the next tick, when all the sync changes were applied.

@fzaninotto fzaninotto added WIP Work In Progress and removed RFR Ready For Review labels Apr 30, 2021
@fzaninotto fzaninotto added RFR Ready For Review and removed WIP Work In Progress labels Apr 30, 2021
@djhi djhi added this to the 3.15 milestone Apr 30, 2021
@djhi djhi merged commit feb7769 into master Apr 30, 2021
@djhi djhi deleted the fix-multiple-hide-filter branch April 30, 2021 08:08
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.

Not possible to hide a few filters
2 participants