fix(kanban): save updated position to store

This fixes a bug where the position of a task would not be calculated correctly when the task was moved next to another recently moved task. The problem was caused by the calculation of the new position referring to the old value of the position attribute, because it was not updated in the local store.

Resolves https://community.vikunja.io/t/kanban-cards-in-wrong-order/2731/6
This commit is contained in:
kolaente 2024-09-05 14:51:47 +02:00
parent 0d9c03e0f2
commit 22e594e253
No known key found for this signature in database
GPG Key ID: F40E70337AB24C9B
1 changed files with 2 additions and 1 deletions

View File

@ -512,6 +512,7 @@ async function updateTaskPosition(e) {
taskId: newTask.id,
})
await taskPositionService.value.update(newPosition)
newTask.position = position
if(bucketHasChanged) {
const updatedTaskBucket = await taskBucketService.value.update(new TaskBucketModel({
@ -524,8 +525,8 @@ async function updateTaskPosition(e) {
if (updatedTaskBucket.bucketId !== newTask.bucketId) {
kanbanStore.moveTaskToBucket(newTask, updatedTaskBucket.bucketId)
}
kanbanStore.setTaskInBucket(newTask)
}
kanbanStore.setTaskInBucket(newTask)
// Make sure the first and second task don't both get position 0 assigned
if (newTaskIndex === 0 && taskAfter !== null && taskAfter.position === 0) {