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