From cd6af2b44b0eb7312886f15a16a0b9c07fd979d0 Mon Sep 17 00:00:00 2001 From: Ville Brofeldt Date: Tue, 9 Mar 2021 10:46:39 +0200 Subject: [PATCH] fix default value and isInitialized to not check strict equality --- .../components/nativeFilters/FilterBar/FilterBar.tsx | 1 - .../src/filters/components/Select/SelectFilterPlugin.tsx | 6 ++---- .../filters/components/TimeGrain/TimeGrainFilterPlugin.tsx | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterBar.tsx b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterBar.tsx index ca72d3cd0515d..f2964a122a39b 100644 --- a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterBar.tsx +++ b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterBar.tsx @@ -218,7 +218,6 @@ const FilterBar: React.FC = ({ filterData[filterConfig.id]?.currentState?.value, ), ); - if (areFiltersInitialized) { handleApply(); setIsInitialized(true); diff --git a/superset-frontend/src/filters/components/Select/SelectFilterPlugin.tsx b/superset-frontend/src/filters/components/Select/SelectFilterPlugin.tsx index d9b8e0b167d44..eb499b61a099e 100644 --- a/superset-frontend/src/filters/components/Select/SelectFilterPlugin.tsx +++ b/superset-frontend/src/filters/components/Select/SelectFilterPlugin.tsx @@ -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 diff --git a/superset-frontend/src/filters/components/TimeGrain/TimeGrainFilterPlugin.tsx b/superset-frontend/src/filters/components/TimeGrain/TimeGrainFilterPlugin.tsx index 1cd7754300b0d..a77075086e870 100644 --- a/superset-frontend/src/filters/components/TimeGrain/TimeGrainFilterPlugin.tsx +++ b/superset-frontend/src/filters/components/TimeGrain/TimeGrainFilterPlugin.tsx @@ -66,7 +66,7 @@ export default function PluginFilterTimegrain( }, }, currentState: { - value: selectedValues, + value: selectedValues.length ? selectedValues : null, }, }, });