Open ifeltsweet opened 1 year ago
I can confirm this is happening for me as well in v3.2.5. The _type
property on the object remains even after the last field is cleared.
We are having the same issue. It really messes things up when you use Zod when we'd need to expect undefined, an empty object, or the filled object
This issue appears to be fixed at least as of 3.49.0 which is the version I tested on. Setting and unsetting a field on an optional object seems to behave as expected. Is that right @ifeltsweet?
Sanity Studio v3 has a regression from v2 for https://github.com/sanity-io/sanity/issues/2630.
Specifically, optional empty objects once touched are not unset, even if all nested fields are empty, thus making all nested validations fail.
To Reproduce
Steps to reproduce the behavior:
Create a simple schema with an optional object that has a required nested field.
Edit the nested field.
Empty the nested field.
Observe that now you are unable to publish the document because nested field validation fails.
Expected behavior
In step 4 the validation should not fail as the whole object should be unset once all nested fields are empty.
Which versions of Sanity are you using?
3.2.6