diff --git a/src/managers/AllDayManager.ts b/src/managers/AllDayManager.ts index 17cc8b6..0fec456 100644 --- a/src/managers/AllDayManager.ts +++ b/src/managers/AllDayManager.ts @@ -183,45 +183,26 @@ export class AllDayManager { const allDayEvents = container.querySelectorAll('swp-event'); - // Calculate required rows - 0 if no events (will collapse) let maxRows = 0; if (allDayEvents.length > 0) { - // Expand events to all dates they span and group by date - const expandedEventsByDate: Record = {}; - + // Track which rows are actually used by checking grid positions + const usedRows = new Set(); + (Array.from(allDayEvents) as HTMLElement[]).forEach((event: HTMLElement) => { - const startISO = event.dataset.start || ''; - const endISO = event.dataset.end || startISO; - const eventId = event.dataset.eventId || ''; - - // Extract dates from ISO strings - const startDate = startISO.split('T')[0]; // YYYY-MM-DD - const endDate = endISO.split('T')[0]; // YYYY-MM-DD - - // Loop through all dates from start to end - let current = new Date(startDate); - const end = new Date(endDate); - - while (current <= end) { - const dateStr = current.toISOString().split('T')[0]; // YYYY-MM-DD format - - if (!expandedEventsByDate[dateStr]) { - expandedEventsByDate[dateStr] = []; - } - expandedEventsByDate[dateStr].push(eventId); - - // Move to next day - current.setDate(current.getDate() + 1); - } + const gridRow = parseInt(getComputedStyle(event).gridRowStart) || 1; + usedRows.add(gridRow); + }); + + // Max rows = highest row number in use + maxRows = usedRows.size > 0 ? Math.max(...usedRows) : 0; + + console.log('🔍 AllDayManager: Height calculation', { + totalEvents: allDayEvents.length, + usedRows: Array.from(usedRows).sort(), + maxRows }); - - // Find max rows needed - maxRows = Math.max( - ...Object.values(expandedEventsByDate).map(ids => ids?.length || 0), - 0 - ); } // Animate to required rows (0 = collapse, >0 = expand)