From f204e79b4dcd65765d7b9c0baa742e02fea71f45 Mon Sep 17 00:00:00 2001 From: Nina Andal Aarvik Date: Fri, 29 Sep 2023 14:04:32 +0200 Subject: [PATCH] fix(core): move reverse() to after map() --- packages/sanity/src/core/field/diff/changes/undoChange.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/sanity/src/core/field/diff/changes/undoChange.ts b/packages/sanity/src/core/field/diff/changes/undoChange.ts index 31bf7347f31..bbfceb48677 100644 --- a/packages/sanity/src/core/field/diff/changes/undoChange.ts +++ b/packages/sanity/src/core/field/diff/changes/undoChange.ts @@ -1,3 +1,4 @@ +import {toArray} from 'rxjs/operators' import { isIndexSegment, isKeyedObject, @@ -56,10 +57,7 @@ export function undoChange( .forEach((child) => undoChange(child, rootDiff, documentOperations)) patches.push( - ...buildUnsetPatches( - rootDiff, - unsetChanges.reverse().map((unsetChange) => unsetChange.path), - ), + ...buildUnsetPatches(rootDiff, unsetChanges.map((unsetChange) => unsetChange.path).reverse()), ) } else if (change.diff.action === 'added') { // The reverse of an add operation is an unset -