diff --git a/kanblendar.js b/kanblendar.js index a633fdc..9b63a3b 100644 --- a/kanblendar.js +++ b/kanblendar.js @@ -255,17 +255,25 @@ class Kanblendar { // 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 dueTime = new Date(task.dataset.dueTime); + const slotStartTime = new Date(`${this.config.currentDate}T${startTime}:00`); const slotEndTime = this.addMinutes(slotStartTime, this.config.interval); - if (!(dueTime >= slotStartTime && dueTime <= slotEndTime)) { + if (startTime) { + const dueTime = new Date(task.dataset.dueTime); + + if (!(dueTime >= slotStartTime && dueTime <= slotEndTime)) { + task.dataset.dueTime = slotStartTime.toISOString(); + } + } else { task.dataset.dueTime = slotStartTime.toISOString(); } } - // Update the task's column in the tasks map + + // Update the task in the tasks map this.tasks.get(task.id).column = dropTarget.id.replace('-tasks', ''); + this.tasks.get(task.id).dueTime = task.dataset.dueTime; this.adjustTimeSlotHeights(); // Adjust heights after dropping a task }