Skip to content

Commit

Permalink
[field] Fix crash on object types without fieldsets property
Browse files Browse the repository at this point in the history
  • Loading branch information
rexxars committed Oct 6, 2020
1 parent aaeebf4 commit 0aafd3d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/@sanity/field/src/diff/changes/buildChangeList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ export function buildObjectChangeList(
): ChangeNode[] {
const changes: ChangeNode[] = []

for (const fieldSet of schemaType.fieldsets) {
const fieldSets = schemaType.fieldsets || schemaType.fields.map(field => ({single: true, field}))
for (const fieldSet of fieldSets) {
if (fieldSet.single) {
changes.push(...buildFieldChange(fieldSet.field, diff, path, titlePath, diffContext))
} else {
Expand Down
2 changes: 1 addition & 1 deletion packages/@sanity/field/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export interface ObjectField<T extends SchemaType = SchemaType> {
export interface ObjectSchemaType<T extends object = Record<string, any>> extends BaseSchemaType {
jsonType: 'object'
fields: ObjectField[]
fieldsets: Fieldset[]
fieldsets?: Fieldset[]
diffComponent?: DiffComponent<ObjectDiff<T>> | DiffComponentOptions<ObjectDiff<T>>
}

Expand Down

0 comments on commit 0aafd3d

Please sign in to comment.