From db9323fd2d44e665378d93d31bf343f8cc2e283d Mon Sep 17 00:00:00 2001
From: Bob Zeleznik <zzzman@gmail.com>
Date: Sat, 6 Jul 2019 19:50:02 -0400
Subject: fixed reordering in stacking view with minimized docs

---
 src/client/views/collections/CollectionStackingView.tsx | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 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 5f81579a8..aea74321e 100644
--- a/src/client/views/collections/CollectionStackingView.tsx
+++ b/src/client/views/collections/CollectionStackingView.tsx
@@ -187,14 +187,14 @@ export class CollectionStackingView extends CollectionSubView(doc => doc) {
             })
         }
         if (super.drop(e, de)) {
-            if (targInd !== -1) {
-                let newDoc = de.data.droppedDocuments[0];
-                let docs = this.childDocList;
-                if (docs) {
-                    let srcInd = docs.indexOf(newDoc);
-                    docs.splice(srcInd, 1);
-                    docs.splice(targInd > srcInd ? targInd - 1 : targInd, 0, newDoc);
-                }
+            let newDoc = de.data.droppedDocuments[0];
+            let docs = this.childDocList;
+            if (docs) {
+                if (targInd === -1) targInd = docs.length;
+                else targInd = docs.indexOf(this.filteredChildren[targInd]);
+                let srcInd = docs.indexOf(newDoc);
+                docs.splice(srcInd, 1);
+                docs.splice(targInd > srcInd ? targInd - 1 : targInd, 0, newDoc);
             }
         }
         return false;
-- 
cgit v1.2.3-70-g09d2

