From 90748ff4fe25f47dfc6aabd46cfc02df079bc126 Mon Sep 17 00:00:00 2001 From: Bartholomew Date: Thu, 7 Nov 2019 20:33:40 +0100 Subject: [PATCH] fix(widget-list): when single field value is object widget (#2387) * fix list widget field * ignore sub list widget --- packages/netlify-cms-widget-list/src/ListControl.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/netlify-cms-widget-list/src/ListControl.js b/packages/netlify-cms-widget-list/src/ListControl.js index 8cfddc8e..4b12b595 100644 --- a/packages/netlify-cms-widget-list/src/ListControl.js +++ b/packages/netlify-cms-widget-list/src/ListControl.js @@ -245,10 +245,13 @@ export default class ListControl extends React.Component { return (fieldName, newValue, newMetadata) => { const { value, metadata, onChange, field } = this.props; const collectionName = field.get('name'); - const newObjectValue = - this.getValueType() !== valueTypes.SINGLE - ? this.getObjectValue(index).set(fieldName, newValue) - : newValue; + const listFieldObjectWidget = field.getIn(['field', 'widget']) === 'object'; + const withNameKey = + this.getValueType() !== valueTypes.SINGLE || + (this.getValueType() === valueTypes.SINGLE && listFieldObjectWidget); + const newObjectValue = withNameKey + ? this.getObjectValue(index).set(fieldName, newValue) + : newValue; const parsedMetadata = { [collectionName]: Object.assign(metadata ? metadata.toJS() : {}, newMetadata || {}), };