From c87d0895b0f78fa724aaec9249771d35d1a93f09 Mon Sep 17 00:00:00 2001 From: Art Lowel Date: Tue, 28 Apr 2020 17:52:01 +0200 Subject: [PATCH] filter out move operations where source and target are the same --- .../sections/form/section-form-operations.service.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/app/submission/sections/form/section-form-operations.service.ts b/src/app/submission/sections/form/section-form-operations.service.ts index 5026319353..6e7a35fe26 100644 --- a/src/app/submission/sections/form/section-form-operations.service.ts +++ b/src/app/submission/sections/form/section-form-operations.service.ts @@ -372,10 +372,14 @@ export class SectionFormOperationsService { pathCombiner.getPath(segmentedPath), value, true); } else { - this.operationsBuilder.move( - pathCombiner.getPath(path), - pathCombiner.getPath(segmentedPath + '/' + event.$event.previousIndex).path - ) + const moveTo = pathCombiner.getPath(path); + const moveFrom = pathCombiner.getPath(segmentedPath + '/' + event.$event.previousIndex); + if (isNotEmpty(moveFrom.path) && isNotEmpty(moveTo.path) && moveFrom.path !== moveTo.path) { + this.operationsBuilder.move( + moveTo, + moveFrom.path + ) + } } } else if (!value.hasValue()) { // New value is empty, so dispatch a remove operation