Skip to content

Commit

Permalink
fix default value and isInitialized to not check strict equality
Browse files Browse the repository at this point in the history
  • Loading branch information
villebro committed Mar 9, 2021
1 parent c6c09a7 commit cd6af2b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ const FilterBar: React.FC<FiltersBarProps> = ({
filterData[filterConfig.id]?.currentState?.value,
),
);

if (areFiltersInitialized) {
handleApply();
setIsInitialized(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,11 @@ export default function PluginFilterSelect(props: PluginFilterSelectProps) {

useEffect(() => {
handleChange(currentValue ?? []);
}, [JSON.stringify(currentValue)]);
}, [JSON.stringify(currentValue), multiSelect, enableEmptyFilter, inverseSelection]);

useEffect(() => {
handleChange(defaultValue ?? []);
// I think after Config Modal update some filter it re-creates default value for all other filters
// so we can process it like this `JSON.stringify` or start to use `Immer`
}, [JSON.stringify(defaultValue)]);
}, [JSON.stringify(defaultValue), multiSelect, enableEmptyFilter, inverseSelection]);

const placeholderText =
(data || []).length === 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default function PluginFilterTimegrain(
},
},
currentState: {
value: selectedValues,
value: selectedValues.length ? selectedValues : null,
},
},
});
Expand Down

0 comments on commit cd6af2b

Please sign in to comment.