fix(widget-relation): clear button (#2285)
This commit is contained in:
parent
a0d974a486
commit
9318aa070b
@ -88,23 +88,28 @@ export default class RelationControl extends React.Component {
|
|||||||
handleChange = selectedOption => {
|
handleChange = selectedOption => {
|
||||||
const { onChange, field } = this.props;
|
const { onChange, field } = this.props;
|
||||||
let value;
|
let value;
|
||||||
|
let metadata;
|
||||||
|
|
||||||
if (Array.isArray(selectedOption)) {
|
if (Array.isArray(selectedOption)) {
|
||||||
value = selectedOption.map(optionToString);
|
value = selectedOption.map(optionToString);
|
||||||
onChange(fromJS(value), {
|
metadata =
|
||||||
[field.get('name')]: {
|
(!isEmpty(selectedOption) && {
|
||||||
[field.get('collection')]: {
|
[field.get('name')]: {
|
||||||
[last(value)]: !isEmpty(selectedOption) && last(selectedOption).data,
|
[field.get('collection')]: {
|
||||||
|
[last(value)]: last(selectedOption).data,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
}) ||
|
||||||
});
|
{};
|
||||||
|
onChange(fromJS(value), metadata);
|
||||||
} else {
|
} else {
|
||||||
value = optionToString(selectedOption);
|
value = optionToString(selectedOption);
|
||||||
onChange(value, {
|
metadata = selectedOption && {
|
||||||
[field.get('name')]: {
|
[field.get('name')]: {
|
||||||
[field.get('collection')]: { [value]: selectedOption.data },
|
[field.get('collection')]: { [value]: selectedOption.data },
|
||||||
},
|
},
|
||||||
});
|
};
|
||||||
|
onChange(value, metadata);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user