From 8f1c32c9f947f01d988304ad452dcdea22d0b891 Mon Sep 17 00:00:00 2001 From: Janus Knudsen Date: Sun, 14 Sep 2025 00:12:34 +0200 Subject: [PATCH] Removes dragged all-day event on header mouseleave Ensures that when dragging an event from the all-day section and the mouse leaves the header, the original all-day event is removed, allowing the cloned event in the day columns to take over seamlessly. This prevents duplicate events from appearing. --- src/managers/DragDropManager.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/managers/DragDropManager.ts b/src/managers/DragDropManager.ts index 4a8a432..cdf541a 100644 --- a/src/managers/DragDropManager.ts +++ b/src/managers/DragDropManager.ts @@ -125,14 +125,16 @@ export class DragDropManager { } }); - // Listen for header mouseleave events (for all-day to timed conversion when leaving header) + // Listen for header mouseleave events (remove all-day event, let clone take over) this.eventBus.on('header:mouseleave', (event) => { - // Check if we're dragging an all-day event - if (this.draggedEventId && this.isAllDayEventBeingDragged()) { - // Convert all-day event to timed event using SwpEventElement factory - this.eventBus.emit('drag:convert-allday-to-timed', { - eventId: this.draggedEventId - }); + // Check if we're dragging ANY event + if (this.draggedEventId) { + // Find and remove all-day event if it exists + const allDayEvent = document.querySelector(`swp-allday-event[data-event-id="${this.draggedEventId}"]`); + if (allDayEvent) { + allDayEvent.remove(); + // Clone i swp-day-columns tager automatisk over + } } }); }