Skip to content

Values from string and markdown widgets come out as either empty string or undefined, depending on whether the field has been edited #1449

@papandreou

Description

@papandreou

- Do you want to request a feature or report a bug?

bug

- What is the current behavior?

String and markdown widgets that are empty produce different data values, depending on whether the field has been edited.

- If the current behavior is a bug, please provide the steps to reproduce.

  1. Define a non-required string field in config.yml:
      -
        label: non-required string field
        name: nonrequiredstring
        widget: string
        required: false
  1. Create a new item in the collection
  2. Don't touch the non-required string field at all
  3. Click Publish

Observe that the nonrequiredstring field isn't in the frontmatter of the resulting markdown file.

  1. Create a new item in the collection
  2. Enter some text in the non-required string field, then delete the text again so the field is blank
  3. Click Publish

Observe that frontmatter of the resulting markdown file contains nonrequiredstringfield: ''

- What is the expected behavior?

That the resulting value is the same in both cases, preferably undefined.

The issue can also be observed for string and markdown widgets showing up in editor components. Also if you open an existing item, remove the text in a field, then Publish.

- Please mention your versions where applicable.

Netlify CMS version: 1.9.2
Browser version: Chrome 67.0.3396.87/OSX

Node.JS version: 10.4.1
Operating System: Mac OSX 10.13.5 (High Sierra)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions