mirror of https://github.com/apache/superset.git
fix: Unable to clear default value in native select filter (#14739)
This commit is contained in:
parent
0e86a6b81c
commit
173c486d4a
|
@ -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 = (
|
||||
|
|
Loading…
Reference in New Issue