Netlify-cms: Removing all values from the list with empty array as default value results in array of one empty string

Created on 25 May 2020  路  4Comments  路  Source: netlify/netlify-cms

Describe the bug
When list widget has empty array as default value, removing all values from it results in array of one empty string

To Reproduce

  - label: Posts
    label_singular: post
    name: post
    fields:
      - {label: Title, name: title, widget: string}
      - {label: Tags, name: tags, widget: list, allow_add: true, required: false, default: []}
      - {label: Body, name: body, widget: markdown}
  1. Create new post
  2. Don't fill the tags input
  3. Publish post
  4. Check the data
---
title: Test
tags: []
---
test
  1. Edit post by adding one tag
  2. Publish and check the data
---
title: Test
tags:
 - tag
---
test
  1. Edit post by removing this tag
  2. Publish and check the data
---
title: Test
tags:
 - ""
---
test

Expected behavior
After removing all tags data should be the following

---
title: Test
tags: []
---
test
good first issue confirmed bug

Most helpful comment

All 4 comments

Was trying to find this list widget, but there are quite a few files there, can you you gimme a hand with finding where it is? Thanks!

Sorry, can't figure out how to fix this :-( Looking through the code, but it doesn't make sense why this would give "" instead of []

I am happy to have a look at this.

Was this page helpful?
0 / 5 - 0 ratings