Skip to content

Commit

Permalink
Fix regression in list relation previews
Browse files Browse the repository at this point in the history
  • Loading branch information
Quicksaver authored and erquhart committed Mar 28, 2018
1 parent a19bc04 commit b205134
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/components/EditorWidgets/List/ListControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,12 @@ export default class ListControl extends Component {

handleChangeFor(index) {
return (fieldName, newValue, newMetadata) => {
const { value, metadata, onChange, forID } = this.props;
const { value, metadata, onChange, field } = this.props;
const collectionName = field.get('name');
const newObjectValue = this.getObjectValue(index).set(fieldName, newValue);
const parsedValue = (this.valueType === valueTypes.SINGLE) ? newObjectValue.first() : newObjectValue;
const parsedMetadata = {
[forID]: Object.assign(metadata ? metadata.toJS() : {}, newMetadata ? newMetadata[forID] : {}),
[collectionName]: Object.assign(metadata ? metadata.toJS() : {}, newMetadata ? newMetadata[collectionName] : {}),
};
onChange(value.set(index, parsedValue), parsedMetadata);
};
Expand All @@ -171,8 +172,9 @@ export default class ListControl extends Component {
handleRemove = (index, event) => {
event.preventDefault();
const { itemsCollapsed } = this.state;
const { value, metadata, onChange, forID } = this.props;
const parsedMetadata = metadata && { [forID]: metadata.removeIn(value.get(index).valueSeq()) };
const { value, metadata, onChange, field } = this.props;
const collectionName = field.get('name');
const parsedMetadata = metadata && { [collectionName]: metadata.removeIn(value.get(index).valueSeq()) };

this.setState({ itemsCollapsed: itemsCollapsed.delete(index) });

Expand Down

0 comments on commit b205134

Please sign in to comment.