Skip to content

Commit

Permalink
[field] Ensure array exists before attempting to insert stub
Browse files Browse the repository at this point in the history
  • Loading branch information
rexxars committed Oct 6, 2020
1 parent f25e216 commit 82c53c4
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions packages/@sanity/field/src/diff/changes/undoChange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ function getParentStubs(path: Path, rootDiff: ObjectDiff, stubbed: Set<string>):
const nextItem = getValueAtPath(value, subPath.concat(nextSegment))
const prevSeg = isKeyedObject(prevItem) ? {_key: prevItem._key} : indexAtPrev - 1
const after = pathToString(subPath.concat(indexAtPrev < 1 ? 0 : prevSeg))
stubs.push({setIfMissing: {[pathStr]: []}})
stubs.push({insert: {after, items: [getStubValue(nextItem)]}})

i++
Expand Down

0 comments on commit 82c53c4

Please sign in to comment.