michael-s-molina commented on issue #14713:
URL: https://github.com/apache/superset/issues/14713#issuecomment-845169249
@villebro After investigation I found that the problem happens because of
the way `rc-field-form` handles the objects comparison in
`src/utils/valueUtil.ts`:
```
function internalSetValues<T>(store: T, values: T): T {
const newStore: T = (Array.isArray(store) ? [...store] : { ...store }) as
T;
if (!values) {
return newStore;
}
Object.keys(values).forEach(function (key) {
var prevValue = newStore[key];
var value = values[key];
var recursive = isObject(prevValue) && isObject(value);
newStore[key] = recursive ? internalSetValues(prevValue, value || {}) :
value;
});
return newStore;
}
```
Since we're setting the property value to an empty object, the
`Object.keys(values)` will return empty and the old value will be returned.
Investigating more, I found these issues in Ant Design Github:
https://github.com/ant-design/ant-design/issues/30212
https://github.com/ant-design/ant-design/issues/28314
https://codesandbox.io/s/antd-reproduction-template-forked-mghsg?file=/App.jsx
This behavior is by design. To fix the problem we should use `setFields`
instead of `setFieldsValue` in
`superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/utils.ts`
```
form.setFieldsValue({
filters: {
...formFilters,
[filterId]: {
...formFilters[filterId],
...values,
},
},
});
```
```
form.setFields([
{
name: 'filters',
value: {
...formFilters,
[filterId]: {
...formFilters[filterId],
...values,
},
},
},
]);
```
https://user-images.githubusercontent.com/70410625/118994963-2479ef00-b95d-11eb-8d56-0728b7961358.mov
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]