From b2051343ccdadfccb6d83701758653902e8141f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Miguel?= Date: Tue, 27 Mar 2018 12:07:38 +0100 Subject: [PATCH] Fix regression in list relation previews --- src/components/EditorWidgets/List/ListControl.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/EditorWidgets/List/ListControl.js b/src/components/EditorWidgets/List/ListControl.js index 37e76897131f..0d7d30a346b6 100644 --- a/src/components/EditorWidgets/List/ListControl.js +++ b/src/components/EditorWidgets/List/ListControl.js @@ -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); }; @@ -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) });