Improves drag and drop conversion behavior

Resets scroll state and stops edge scrolling when a drag event converts between all-day and timed events, preventing unexpected scrolling behavior during conversion.
This commit is contained in:
Janus C. H. Knudsen 2025-10-13 22:17:17 +02:00
parent 3fd42f1f9b
commit 1d04f0ce0a
3 changed files with 23 additions and 1 deletions

View file

@ -143,6 +143,19 @@ export class DragDropManager {
console.log('🛑 DragDropManager: Edge-scroll stopped'); console.log('🛑 DragDropManager: Edge-scroll stopped');
}); });
// Reset scrollDeltaY when event converts (new clone created)
this.eventBus.on('drag:mouseenter-header', () => {
console.log('🔄 DragDropManager: Event converting to all-day - resetting scrollDeltaY');
this.scrollDeltaY = 0;
this.lastScrollTop = 0;
});
this.eventBus.on('drag:mouseenter-column', () => {
console.log('🔄 DragDropManager: Event converting to timed - resetting scrollDeltaY');
this.scrollDeltaY = 0;
this.lastScrollTop = 0;
});
} }
private handleGridRendered(event: CustomEvent) { private handleGridRendered(event: CustomEvent) {
this.scrollableContent = document.querySelector('swp-scrollable-content'); this.scrollableContent = document.querySelector('swp-scrollable-content');

View file

@ -60,6 +60,16 @@ export class EdgeScrollManager {
this.eventBus.on('drag:end', () => this.stopDrag()); this.eventBus.on('drag:end', () => this.stopDrag());
this.eventBus.on('drag:cancelled', () => this.stopDrag()); this.eventBus.on('drag:cancelled', () => this.stopDrag());
// Stop scrolling when event converts to/from all-day
this.eventBus.on('drag:mouseenter-header', () => {
console.log('🔄 EdgeScrollManager: Event converting to all-day - stopping scroll');
this.stopDrag();
});
this.eventBus.on('drag:mouseenter-column', () => {
this.startDrag();
});
} }
private startDrag(): void { private startDrag(): void {

View file

@ -91,7 +91,6 @@ export class DateEventRenderer implements EventRendererStrategy {
*/ */
public handleDragMove(payload: DragMoveEventPayload): void { public handleDragMove(payload: DragMoveEventPayload): void {
console.log('handleDragMove', payload)
const swpEvent = payload.draggedClone as SwpEventElement; const swpEvent = payload.draggedClone as SwpEventElement;
const columnDate = this.dateService.parseISO(payload.columnBounds!!.date); const columnDate = this.dateService.parseISO(payload.columnBounds!!.date);
swpEvent.updatePosition(columnDate, payload.snappedY); swpEvent.updatePosition(columnDate, payload.snappedY);