From 313bed0a3b459e12f1e003fff844fd47425fde0b Mon Sep 17 00:00:00 2001
From: Geireann Lindfield Roberts <60007097+geireann@users.noreply.github.com>
Date: Wed, 21 Oct 2020 05:53:40 +0800
Subject: fixed dragging multiple elements

(sometimes still deletes slides from trail)
---
 src/client/views/collections/CollectionStackingView.tsx | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

(limited to 'src/client/views/collections/CollectionStackingView.tsx')

diff --git a/src/client/views/collections/CollectionStackingView.tsx b/src/client/views/collections/CollectionStackingView.tsx
index 2fedca711..4eb6ee03c 100644
--- a/src/client/views/collections/CollectionStackingView.tsx
+++ b/src/client/views/collections/CollectionStackingView.tsx
@@ -297,9 +297,11 @@ export class CollectionStackingView extends CollectionSubView<StackingDocument,
                     newDocs.map((doc, i) => {
                         targInd = targInd === -1 ? docs.length : targInd;
                         const srcInd = docs.indexOf(doc);
-                        if (targInd !== -1) targInd = i === 0 ? docs.indexOf(this.filteredChildren[targInd]) : docs.indexOf(newDocs[0]) + 1;
+                        // if (i !== 0) console.log(docs.indexOf(newDocs[0])); //glr: for testing
+                        if (targInd !== -1) targInd = i === 0 ? docs.indexOf(this.filteredChildren[targInd]) : docs.indexOf(newDocs[i - 1]) + 1;
+                        // console.log("title: " + doc.title, "i: " + i, "targInd: " + targInd, "length: " + newDocs.length, "srcInd: " + srcInd); //glr: for testing
                         docs.splice(srcInd, 1);
-                        docs.splice((targInd > srcInd ? targInd - 1 : targInd) + plusOne, 0, doc);
+                        docs.splice((targInd > srcInd ? targInd - 1 : targInd) + (i === 0 ? plusOne : 0), 0, doc);
                     });
                 }
             }
-- 
cgit v1.2.3-70-g09d2

