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.
This commit is contained in:
Janus Knudsen 2025-09-14 00:12:34 +02:00
parent cd079f7641
commit 8f1c32c9f9

View file

@ -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) => { this.eventBus.on('header:mouseleave', (event) => {
// Check if we're dragging an all-day event // Check if we're dragging ANY event
if (this.draggedEventId && this.isAllDayEventBeingDragged()) { if (this.draggedEventId) {
// Convert all-day event to timed event using SwpEventElement factory // Find and remove all-day event if it exists
this.eventBus.emit('drag:convert-allday-to-timed', { const allDayEvent = document.querySelector(`swp-allday-event[data-event-id="${this.draggedEventId}"]`);
eventId: this.draggedEventId if (allDayEvent) {
}); allDayEvent.remove();
// Clone i swp-day-columns tager automatisk over
}
} }
}); });
} }