From abed596f79e3d11348a990dc99a606fe6d35bed2 Mon Sep 17 00:00:00 2001 From: Neil Brommer Date: Thu, 28 Dec 2017 13:41:36 -0800 Subject: [PATCH] Fix bug when moving groups up the list --- js/editBookmarks.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/js/editBookmarks.js b/js/editBookmarks.js index 39da627..a492742 100644 --- a/js/editBookmarks.js +++ b/js/editBookmarks.js @@ -62,10 +62,19 @@ function groupMoved(dropEvt) { groupsStore.getAll().onsuccess = function (evt) { var groups = evt.target.result; - for (let g of groups) { - if (g.groupIndex > oldIndex && g.groupIndex <= newIndex) { - g.groupIndex--; - groupsStore.put(g); + if (newIndex > oldIndex) { + for (let g of groups) { + if (g.groupIndex > oldIndex && g.groupIndex <= newIndex) { + g.groupIndex--; + groupsStore.put(g); + } + } + } else { // oldIndex > newIndex + for (let g of groups) { + if (g.groupIndex < oldIndex && g.groupIndex >= newIndex) { + g.groupIndex++; + groupsStore.put(g); + } } }