From e2c81d840f35c47167592bb7ca21648a09cef6e8 Mon Sep 17 00:00:00 2001 From: Dominik Pschenitschni Date: Wed, 9 Feb 2022 00:25:37 +0100 Subject: [PATCH] fix: hack to fix wrong index position --- src/views/list/ListKanban.vue | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/views/list/ListKanban.vue b/src/views/list/ListKanban.vue index c10b3659..3691b373 100644 --- a/src/views/list/ListKanban.vue +++ b/src/views/list/ListKanban.vue @@ -407,10 +407,25 @@ export default { // of the drop target works all the time. const bucketIndex = parseInt(e.to.dataset.bucketIndex) + const newBucket = this.buckets[bucketIndex] - const task = newBucket.tasks[e.newIndex] - const taskBefore = newBucket.tasks[e.newIndex - 1] ?? null - const taskAfter = newBucket.tasks[e.newIndex + 1] ?? null + + // HACK: + // this is a hacky workaround for a known problem of vue.draggable.next when using the footer slot + // the problem: https://github.com/SortableJS/vue.draggable.next/issues/108 + // This hack doesn't remove the problem that the ghost item is still displayed below the footer + // It just makes releasing the item possible. + + // The newIndex of the event doesn't count in the elements of the footer slot. + // This is why in case the length of the tasks is identical with the newIndex + // we have to remove 1 to get the correct index. + const newTaskIndex = newBucket.tasks.length === e.newIndex + ? e.newIndex - 1 + : e.newIndex + + const task = newBucket.tasks[newTaskIndex] + const taskBefore = newBucket.tasks[newTaskIndex - 1] ?? null + const taskAfter = newBucket.tasks[newTaskIndex + 1] ?? null const newTask = cloneDeep(task) // cloning the task to avoid vuex store mutations newTask.bucketId = newBucket.id,