From fe5381dcb8ceff05b2f21c4098387730c42df041 Mon Sep 17 00:00:00 2001 From: simcha90 <56388545+simcha90@users.noreply.github.com> Date: Thu, 17 Jun 2021 11:14:21 +0300 Subject: [PATCH] fix(native-filters): Fix Select `Default First Value` by clicked `Clear All` (#15219) * fix:fix get permission function * fix: fix select first value by clear all * lint: fix lint --- .../components/nativeFilters/FilterBar/Header/index.tsx | 6 +++++- superset-frontend/src/dataMask/reducer.ts | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/Header/index.tsx b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/Header/index.tsx index a199ff7251..0ff53bf5c8 100644 --- a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/Header/index.tsx +++ b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/Header/index.tsx @@ -92,7 +92,11 @@ const Header: FC = ({ const handleClearAll = () => { filterValues.forEach(filter => { setDataMaskSelected(draft => { - draft[filter.id] = getInitialDataMask(filter.id); + draft[filter.id] = getInitialDataMask(filter.id, { + filterState: { + value: null, + }, + }); }); }); }; diff --git a/superset-frontend/src/dataMask/reducer.ts b/superset-frontend/src/dataMask/reducer.ts index 275787e0db..81c55a3498 100644 --- a/superset-frontend/src/dataMask/reducer.ts +++ b/superset-frontend/src/dataMask/reducer.ts @@ -37,8 +37,11 @@ import { import { areObjectsEqual } from '../reduxUtils'; import { Filters } from '../dashboard/reducers/types'; -export function getInitialDataMask(id?: string): DataMask; -export function getInitialDataMask(id: string): DataMaskWithId { +export function getInitialDataMask(id?: string, moreProps?: DataMask): DataMask; +export function getInitialDataMask( + id: string, + moreProps: DataMask = {}, +): DataMaskWithId { let otherProps = {}; if (id) { otherProps = { @@ -52,6 +55,7 @@ export function getInitialDataMask(id: string): DataMaskWithId { value: undefined, }, ownState: {}, + ...moreProps, } as DataMaskWithId; }