Skip to content

Commit

Permalink
fix: remove empty list item (#3245)
Browse files Browse the repository at this point in the history
  • Loading branch information
barthc committed Feb 13, 2020
1 parent 2447f9c commit f915bf3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/netlify-cms-widget-list/src/ListControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f915bf3

Please sign in to comment.