From 5c5473ad7b8b196e7b419c10c14a24cf7b78d522 Mon Sep 17 00:00:00 2001 From: Kumi Date: Wed, 31 Jul 2024 11:47:25 +0200 Subject: [PATCH] fix(tasks): ensure correct column association on move Reordered event emission to after updating task data. Added dataset updates for task's parent column to maintain a consistent state. This prevents bugs where tasks could end up in incorrect columns after moving. Adjusts heights for consistent UI. --- kanblendar.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/kanblendar.js b/kanblendar.js index 9b63a3b..999fc5c 100644 --- a/kanblendar.js +++ b/kanblendar.js @@ -249,12 +249,12 @@ class Kanblendar { if (dropTarget.classList.contains('kanblendar-time-slot') || dropTarget.classList.contains('kanblendar-non-timed-tasks')) { dropTarget.appendChild(task); - this.emitTaskChangedEvent('move', task); } // Update the task's due time if dropped in a time slot and the current due time is not valid for that slot if (dropTarget.classList.contains('kanblendar-time-slot')) { const startTime = dropTarget.dataset.startTime; + const parentColumn = dropTarget.closest('.kanblendar-column').id; const slotStartTime = new Date(`${this.config.currentDate}T${startTime}:00`); const slotEndTime = this.addMinutes(slotStartTime, this.config.interval); @@ -268,14 +268,17 @@ class Kanblendar { } else { task.dataset.dueTime = slotStartTime.toISOString(); } + + task.dataset.column = parentColumn.replace('-tasks', ''); } - // Update the task in the tasks map - this.tasks.get(task.id).column = dropTarget.id.replace('-tasks', ''); + this.tasks.get(task.id).column = task.dataset.column; this.tasks.get(task.id).dueTime = task.dataset.dueTime; this.adjustTimeSlotHeights(); // Adjust heights after dropping a task + + this.emitTaskChangedEvent('move', task); } openModal(task = null) {