fix(widget-relation): handle optional configuration (#4256)

This commit is contained in:
Flo 2020-09-06 18:21:19 +00:00 committed by GitHub
parent 6b8fa3fc45
commit 9217e10e06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -148,7 +148,7 @@ export default class RelationControl extends React.Component {
let metadata;
if (Array.isArray(selectedOption)) {
this.setState({ initialOptions: selectedOption });
this.setState({ initialOptions: selectedOption.filter(Boolean) });
value = selectedOption.map(optionToString);
metadata =
(!isEmpty(selectedOption) && {
@ -161,7 +161,7 @@ export default class RelationControl extends React.Component {
{};
onChange(fromJS(value), metadata);
} else {
this.setState({ initialOptions: [selectedOption] });
this.setState({ initialOptions: [selectedOption].filter(Boolean) });
value = optionToString(selectedOption);
metadata = selectedOption && {
[field.get('name')]: {