strapi icon indicating copy to clipboard operation
strapi copied to clipboard

A non-required json input field blocks update save silently when empty

Open segovia opened this issue 1 year ago • 0 comments

Bug report

Required System information

  • Environment: development
  • OS: linux-x64
  • Strapi Version: 4.19.0
  • Node/Yarn Version: yarn/3.6.3 npm/? node/v18.17.1 linux x64
  • Edition: Community
  • Database: postgres
  • Is your project Javascript or Typescript: Typescript

Describe the bug

I have a custom content type called Person with 2 fields:

  • name (required text)
  • info (non-required json field)

When creating an instance of Person, via the admin console, everything works as expected. I fill in 'name', leave 'info' empty and press 'Save'. This creates an entry of Person where 'info' is null. That is fine.

The issue happens when I edit Person. If I remove/empty the contents in the text box of 'info' and press save, nothing happens. I don't get any feedback whether something was actually saved or if an error occurred.

This behavior is very confusing, since you actually believe the content was saved but it actually wasn't. The bug happens if the previous value of the json input field was null or any json.

Expected behavior

I would expect the behavior of editing content to be inline with creating. Which means that, if I empty out the json input field and press save, it will be set to null.

segovia avatar Feb 11 '24 12:02 segovia