Skip to content

Rich Text (Blocks) - should save as NULL if no text length is 0 #23309

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
2 tasks done
heggland opened this issue Apr 3, 2025 · 0 comments
Open
2 tasks done

Rich Text (Blocks) - should save as NULL if no text length is 0 #23309

heggland opened this issue Apr 3, 2025 · 0 comments
Labels
issue: bug Issue reporting a bug severity: low If the issue only affects a very niche base of users and an easily implemented workaround can solve source: core:content-manager Source is core/content-manager package status: pending reproduction Waiting for free time to reproduce the issue, or more information version: 4 Issue related to v4 version: 5

Comments

@heggland
Copy link

heggland commented Apr 3, 2025

Node Version

20.9.0

NPM/Yarn/PNPM Version

Yarn 1.22.19

Strapi Version

5.8.1

Operating System

Linux (Other)

Database

PostgreSQL

Javascript or Typescript

Typescript

Reproduction URL

No response

Bug Description

Rich Text (Blocks) is saving as a object [{"type": "paragraph", "children": [{"text": "", "type": "text"}]}] when there is no text in the field.

Image

Image

Steps to Reproduce

  1. Write into the blocks field, e.g. "this is a test"
  2. Press save.
  • It stores the field as: [{"type": "paragraph", "children": [{"text": "this is a test", "type": "text"}]}]
  1. Clear the blocks field.
  2. Press save
  • It stores the field as: [{"type": "paragraph", "children": [{"text": "", "type": "text"}]}] when it should store it as NULL

Expected Behavior

When I clear the blocks field, remove all text in the field, it should store it as NULL value.

Logs

Code Snippets

if the slogan is stored as NULL after its updated--cleared out- I wouldn't need the else statement at line 18 nor have the extensive check. Also if there are two arrays inside the children object, it would be printed out twice.


1                {!slogan && t("heroSlogan")}
2                {slogan &&
3                 Array.isArray(slogan) &&
4                  slogan.map((s) =>
5                    s.children.map(
6                     (c, i) =>
7                        (c.text && (
8                         <span
9                            key={i}
10                           style={{
11                              fontWeight: c.bold ? "bold" : "lighter",
12                             textDecoration: c.underline ? "underline" : "none"
13                            }}
14                          >
15                            {c.text}
16                          </span>
17                        )) ||
18                        t("heroSlogan") 
19                    )
20                  )}

Media

Image
screenshot from the postgresdb, left has text where the right doesnt- but still stored as object.

Image
DOM inspect, the length value could be used to determinate if the field should be stored as object or NULL?

Additional information

No response

Confirmation Checklist

@derrickmehaffy derrickmehaffy added severity: low If the issue only affects a very niche base of users and an easily implemented workaround can solve source: core:content-manager Source is core/content-manager package status: pending reproduction Waiting for free time to reproduce the issue, or more information version: 5 version: 4 Issue related to v4 labels Apr 10, 2025
@derrickmehaffy derrickmehaffy added the issue: bug Issue reporting a bug label Apr 10, 2025
@github-project-automation github-project-automation bot moved this to To be reviewed in Content Squad Apr 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: bug Issue reporting a bug severity: low If the issue only affects a very niche base of users and an easily implemented workaround can solve source: core:content-manager Source is core/content-manager package status: pending reproduction Waiting for free time to reproduce the issue, or more information version: 4 Issue related to v4 version: 5
Projects
Status: To be reviewed
Status: To triage
Development

No branches or pull requests

2 participants