Improves drag and drop behavior

Hides the drag clone when moving events to the all-day area and shows it again when the mouse leaves the header to prevent visual inconsistencies.
Ensures only the correct all-day event is removed by specifying the container in the selector.
This commit is contained in:
Janus Knudsen 2025-09-14 00:32:27 +02:00
parent 8f1c32c9f9
commit 7e45293128

View file

@ -107,6 +107,12 @@ export class DragDropManager {
originalElement: draggedElement,
headerRenderer
});
// Hide drag clone completely
const dragClone = document.querySelector(`swp-event[data-event-id="clone-${this.draggedEventId}"]`);
if (dragClone) {
(dragClone as HTMLElement).style.display = 'none';
}
}
}
});
@ -129,11 +135,16 @@ export class DragDropManager {
this.eventBus.on('header:mouseleave', (event) => {
// 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}"]`);
// Find and remove all-day event specifically in the container
const allDayEvent = document.querySelector(`swp-allday-container swp-allday-event[data-event-id="${this.draggedEventId}"]`);
if (allDayEvent) {
allDayEvent.remove();
// Clone i swp-day-columns tager automatisk over
}
// Show drag clone again
const dragClone = document.querySelector(`swp-event[data-event-id="clone-${this.draggedEventId}"]`);
if (dragClone) {
(dragClone as HTMLElement).style.display = 'block';
}
}
});