From 35651be2f0801ff4a8ce7e907bfcd194250c094a Mon Sep 17 00:00:00 2001 From: "Janus C. H. Knudsen" Date: Sun, 21 Sep 2025 22:17:24 +0200 Subject: [PATCH] Ensures accurate all-day event placement Reorders operations to calculate grid position for all-day events before appending them to the DOM. This prevents the element from being incorrectly counted during position calculations, improving placement accuracy. --- src/managers/AllDayManager.ts | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/managers/AllDayManager.ts b/src/managers/AllDayManager.ts index 0fec456..e0887cc 100644 --- a/src/managers/AllDayManager.ts +++ b/src/managers/AllDayManager.ts @@ -291,26 +291,20 @@ export class AllDayManager { } } - // Move clone element to all-day container - allDayContainer.appendChild(cloneElement); - - // Add CSS class for all-day styling - cloneElement.classList.add('all-day-style'); - - // Store target date for positioning - cloneElement.dataset.allDayDate = targetDate; - - // Calculate and set grid column based on targetDate + // Calculate position BEFORE adding to container (to avoid counting clone as existing event) const columnIndex = this.getColumnIndexForDate(targetDate); - cloneElement.style.gridColumn = columnIndex.toString(); - - // Find available row and set grid row const availableRow = this.findAvailableRow(targetDate); - cloneElement.style.gridRow = availableRow.toString(); - // Show the element (ensure it's visible) + // Set all properties BEFORE adding to DOM + cloneElement.classList.add('all-day-style'); + cloneElement.style.gridColumn = columnIndex.toString(); + cloneElement.style.gridRow = availableRow.toString(); + cloneElement.dataset.allDayDate = targetDate; cloneElement.style.display = ''; + // NOW add to container (after all positioning is calculated) + allDayContainer.appendChild(cloneElement); + console.log('✅ AllDayManager: Converted to all-day style', { eventId: cloneElement.dataset.eventId, gridColumn: columnIndex,