Possible Bug in CMS Online Editor When Empty Text Fields Are Saved

Description

When creating a new post that contains front matter fields of type TEXT, leaving one of these fields empty and saving the post multiple times causes the field value to change unexpectedly.

The first save behaves correctly. However, after the post is saved a second time, the previously empty field is written as [] instead of remaining empty.

This creates an empty array. When the field is rendered on the website, the value is displayed as “Array” rather than as an empty string.

If text is subsequently entered into the field, it is stored as an element within the array instead of as a normal text value.

Expected behaviour

  • Saving a post with an empty TEXT field should leave the field empty.
  • Saving the post multiple times should not change the field type or value.
  • If text is entered later, it should be stored as a normal text string.

Actual behaviour

  • After the post is saved a second time, an empty TEXT field is changed to [].
  • If text is later entered into the field, it is stored as an array element rather than as plain text.
  • When rendered on the website, the field displays “Array” instead of the expected text.

Steps to reproduce

  1. Create a new post.
  2. Leave a TEXT field empty.
  3. Save the post.
  4. Make any change to the post (or simply save it again).
  5. Save the post a second time.
  6. Observe that the previously empty field now contains [].
  7. Enter text into that field and save again.
  8. Observe that the text is stored as an array element rather than as plain text.

File Contents

The first rule in the elements CMS Club is:

Put your data fields in the frontmatter in quotation marks.

This applies especially to:

title: "Bracket Test 4"
headline: "Headline"
sub_title: "Subtitle"

If you want to output headline and sub_title with brackets, write them like this:

headline: "[Headline]"
sub_title: "[Subtitle]"

The use of brackets only works in this way for:

tags
categories

Thanks, but this is the action of the CMS editor, not me! The bug is that the editor adds the spurious brackets. It also decides when to add quotation marks (when there are characters that need to be escaped) and also, on occasion, removes quotation marks that it assesses are unnecessary.

Sorry, my mistake. I skimmed through it a bit too quickly.

In that case, it looks like there are indeed a few more issues with the CMS online editor. I actually don’t use it myself.

We should probably bring this post to the attention of @Ben or @Dan, so hopefully you can either get a bug fix soon or at least some information about a useful workaround or similar solution.

No problem! Thanks for taking the time to reply!

Hi @BrettHannam

Thanks for the detailed report, that really helps. I’m going to look at this issue asap, hopefully we can get it fixed in time for the next update.

Thanks @Ben - that’s very helpful.

found the issue, this will be fixed in the next build :slight_smile:

Terrific! Thank you very much indeed.