fix: Unable to clear default value in native select filter (#14739)

This commit is contained in:
Michael S. Molina 2021-05-20 23:42:33 -03:00 committed by GitHub
parent 0e86a6b81c
commit 173c486d4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 8 deletions

View File

@ -21,6 +21,8 @@ import { FormInstance } from 'antd/lib/form';
import React from 'react';
import { CustomControlItem } from '@superset-ui/chart-controls';
const FILTERS_FIELD_NAME = 'filters';
export const useForceUpdate = () => {
const [, updateState] = React.useState({});
return React.useCallback(() => updateState({}), []);
@ -31,16 +33,19 @@ export const setNativeFilterFieldValues = (
filterId: string,
values: object,
) => {
const formFilters = form.getFieldValue('filters') || {};
form.setFieldsValue({
filters: {
...formFilters,
[filterId]: {
...formFilters[filterId],
...values,
const formFilters = form.getFieldValue(FILTERS_FIELD_NAME) || {};
form.setFields([
{
name: FILTERS_FIELD_NAME,
value: {
...formFilters,
[filterId]: {
...formFilters[filterId],
...values,
},
},
},
});
]);
};
export const getControlItems = (