Skip to content

Commit

Permalink
fix(form): respect enableHiddenCheck condition in formState
Browse files Browse the repository at this point in the history
Return null here only when enableHiddenCheck, or we end up with array members that have 'item: null' when they
really should not be. One example is when a block object inside the PT-input have a type with one single hidden field.
Then it should still be possible to see the array member item, even though all of it's fields are null.
  • Loading branch information
skogsmaskin authored and mariuslundgard committed Oct 3, 2022
1 parent 3a71e15 commit 7f20cca
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/sanity/src/form/store/formState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,10 @@ function prepareObjectInputState<T>(
.filter((item) => isEqual(item.path, props.path))
.map((v) => ({level: v.level, message: v.item.message, path: v.path}))

if (members.length === 0) {
// Return null here only when enableHiddenCheck, or we end up with array members that have 'item: null' when they
// really should not be. One example is when a block object inside the PT-input have a type with one single hidden field.
// Then it should still be possible to see the member item, even though all of it's fields are null.
if (members.length === 0 && enableHiddenCheck) {
return null
}

Expand Down

0 comments on commit 7f20cca

Please sign in to comment.