You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2021/05/19 14:15:57 UTC
[GitHub] [superset] villebro opened a new issue #14713: Unable to clear default value in native select filter
villebro opened a new issue #14713:
URL: https://github.com/apache/superset/issues/14713
### Expected results
When setting a default value to a select filter and clearing it, the `extraFormData` isn't cleared. This is happening because AntD form isn't able to set a nested object to empty, but rather leaves the old one in place. See a related discussion here: https://github.com/ant-design/ant-design/issues/8806#issuecomment-379543118
what you expected to happen.
### Actual results
what actually happens.
#### Screenshots
If applicable, add screenshots to help explain your problem.
#### How to reproduce the bug
Add a default value:

Remove default value:

When going back to the dashboard, notice how the filter state is empty, but it's trying to apply `extraFormData` to charts:

Check Redux and see, that `extraFormData` was not reset to an empty object, despite having been updated by `setDataMask`:

### Checklist
Make sure to follow these steps before submitting your issue - thank you!
- [ ] I have checked the superset logs for python stacktraces and included it here as text if there are any.
- [ ] I have reproduced the issue with at least the latest released version of superset.
- [ ] I have checked the issue tracker for the same issue and I haven't found one similar.
### Additional context
Add any other context about the problem here.
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [superset] villebro commented on issue #14713: Unable to clear default value in native select filter
Posted by GitBox <gi...@apache.org>.
villebro commented on issue #14713:
URL: https://github.com/apache/superset/issues/14713#issuecomment-845224220
Awesome detective work @michael-s-molina - please open a PR to claim due credit for this!
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [superset] pkdotson closed issue #14713: Unable to clear default value in native select filter
Posted by GitBox <gi...@apache.org>.
pkdotson closed issue #14713:
URL: https://github.com/apache/superset/issues/14713
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [superset] michael-s-molina commented on issue #14713: Unable to clear default value in native select filter
Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org