-
Notifications
You must be signed in to change notification settings - Fork 78
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
LF-4226 fix clear filters button does not clear filters #3474
base: integration
Are you sure you want to change the base?
Conversation
@@ -116,7 +116,7 @@ export const FilterMultiSelectV2 = ({ | |||
|
|||
useEffect(() => { | |||
if (shouldReset) { | |||
setValue(options.filter((option) => option.default)); | |||
setValue([]); |
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.
The default filters in options
are the filters that were initially active when the filter modal is opened, empty array removes all selected options
@@ -14,7 +14,14 @@ | |||
*/ | |||
|
|||
// In tempStateReducer > filterReducer | |||
export type ReduxFilterEntity<FilterKey extends string = string> = Record<FilterKey, FilterState>; | |||
export type ReduxFilterEntity<FilterKey extends string = string> = Record<FilterKey, FilterState> & |
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.
Unlike the other filters, the date filters have a string type. In order to set the filter inactive the filter value needs to be set to undefined rather than using an active
flag. I need to explicitly specify this type here in order to reset to undefined in FilterPage/index.tsx
.
Description
This PR fixes the issue where clicking "clear all filters" in the filter modal has no effect in updating the filters. The changes are based on a previous PR #3218 with some additional edits. I explored an alternative solution in #3440 that clears the filters using a useEffect in every filter but I figured this method of handling the logic in one place would be better.
Jira link: LF-4226
Type of change
How Has This Been Tested?
Tested changes on the following pages: crop catalogue, crop variety, documents, tasks
Checklist: