From f915bf375fc8faa9b4ed5b3684861dfbe462a032 Mon Sep 17 00:00:00 2001 From: Bartholomew Date: Thu, 13 Feb 2020 10:59:38 +0100 Subject: [PATCH] fix: remove empty list item (#3245) --- packages/netlify-cms-widget-list/src/ListControl.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/netlify-cms-widget-list/src/ListControl.js b/packages/netlify-cms-widget-list/src/ListControl.js index 28dea2a4..abc2fd4f 100644 --- a/packages/netlify-cms-widget-list/src/ListControl.js +++ b/packages/netlify-cms-widget-list/src/ListControl.js @@ -273,7 +273,10 @@ export default class ListControl extends React.Component { const isSingleField = this.getValueType() === valueTypes.SINGLE; const metadataRemovePath = isSingleField ? value.get(index) : value.get(index).valueSeq(); - const parsedMetadata = metadata && { [collectionName]: metadata.removeIn(metadataRemovePath) }; + const parsedMetadata = + metadata && !metadata.isEmpty() + ? { [collectionName]: metadata.removeIn(metadataRemovePath) } + : metadata; // Removed item object index is the last item in the list const removedItemIndex = value.count() - 1;