Structured Text Error

If you add text inside of a Structured Text field, save the document, then delete all of the text within that field, and save again, there seems to be an empty paragraph and break tag left over?

This is causing some annoying issues on the front end, as now I need to check for the field being empty OR the field containing these empty tags e.g. empty.

Not the end of the world by any means, but would love to know if there was a way to fix it!

1 Like

Hey Tim,

Sorry I missed this.

Can you tell what development kit your are using and what is being returned in your api response after you delete the text?

Thanks.

Hey Phil,

Thanks for following up!

I’m using graphql, and the results are below from the Prismic GraphiQL interface.

So you can replicate, all you need to do is make a new custom type with a Rich Text Field, that supports paragraphs (and multiple paragraphs), e.g. the default type of rich text.

Then if you follow the 3 steps below, you will see how the empty paragraph tag and line break is orphaned in the field, which is still sent to the output.

Step 1) Create new document, save and publish. Do not add any data to the fields. View in GraphiQL:

{
  "data": {
    "article": {
      "footnote": null,
    }
  }
}

Step 2) Enter some content into the field, save and publish. View in GraphiQL:

{
  "data": {
    "article": {
      "footnote": [
        {
          "type": "paragraph",
          "text": "test",
          "spans": []
        }
      ],
    }
  }
}

Step 3) Deleting the content from the field (e.g. completely empty field), save and publish. View in GraphiQL:

{
  "data": {
    "article": {
      "footnote": [
        {
          "type": "paragraph",
          "text": "",
          "spans": []
        }
      ],
    }
  }
}

OK, got you now.

We are aware of this. I believe this was a choice from the team, I can’t remember exactly the reasoning, so I’m going to contact them for extra information on this. Once I know more I’ll update you here.

Thanks @Phil,

I’ll be interested to hear what the team says, or has in store for this.

Might be handy for others to know as well, because I was scratching my head for a while there.
I was obviously expecting a null response but couldn’t figure out why I was getting an empty paragraph.

So on the front end you must check for null as well as an empty paragraph string within the results array/object, if you don’t want extra spaces!

Cheers,

So I talked with some of the team and there doesn’t appear to be structural reason why returning the data like this is necessary and the team will now begin making plans to fix this.

I don’t have an ETA of when/if they will do this, but as soon as they have more information or have anymore questions, they will get update you here.

Thanks.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.