Skip to content

Commit

Permalink
fix(core): don't iterate on target schemaType if sourceValue is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
skogsmaskin committed Jun 17, 2024
1 parent 0e2ae36 commit a6c6202
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/sanity/src/core/studio/copyPaste/__test__/schema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ const nestedObjectType = defineType({
name: 'objectList',
of: [{type: 'nestedObject'}],
},
{
type: 'object',
name: 'recursiveTest',
fields: [
{
name: 'recursive',
type: 'nestedObject',
},
],
},
],
})

Expand Down
6 changes: 6 additions & 0 deletions packages/sanity/src/core/studio/copyPaste/valueTransfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,12 @@ function collateObjectValue({
errors: TransferValueError[]
keyGenerator: () => string
}) {
if (isEmptyValue(sourceValue)) {
return {
targetValue: undefined,
errors,
}
}
if (targetSchemaType.readOnly) {
return {
targetValue: undefined,
Expand Down

0 comments on commit a6c6202

Please sign in to comment.