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.
This commit is contained in:
Janus C. H. Knudsen 2025-09-21 22:17:24 +02:00
parent c9b9ac4cae
commit 35651be2f0

View file

@ -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,