-
-
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 hideFilter called repeatedly only registers the last call #6226
Conversation
@@ -229,38 +240,18 @@ const useListParams = ({ | |||
); | |||
|
|||
const hideFilter = useCallback((filterName: string) => { | |||
// we don't use lodash.set() for displayed filters |
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 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 |
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.
Same, this change is just cosmetic
@@ -163,21 +164,31 @@ const useListParams = ({ | |||
}, []); // eslint-disable-line | |||
|
|||
const changeParams = useCallback(action => { |
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 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.
Closes #6055