From c7b9abde9ac246f6aec8a5e555c9fec6b83b4578 Mon Sep 17 00:00:00 2001 From: "Janus C. H. Knudsen" Date: Tue, 30 Sep 2025 22:49:16 +0200 Subject: [PATCH] Improves all-day event height calculation. Refactors all-day event height calculation to use the `currentLayouts` array, ensuring more accurate and reliable height adjustments. This avoids querying the DOM directly and relies on the existing layout data for improved performance and correctness. --- src/managers/AllDayManager.ts | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/managers/AllDayManager.ts b/src/managers/AllDayManager.ts index cb93988..19f7fda 100644 --- a/src/managers/AllDayManager.ts +++ b/src/managers/AllDayManager.ts @@ -169,28 +169,25 @@ export class AllDayManager { * Check current all-day events and animate to correct height */ public checkAndAnimateAllDayHeight(): void { - const container = this.getAllDayContainer(); - - const allDayEvents = container?.querySelectorAll('swp-event'); - //use currentLayouts here instead of the queryselector - - - // Calculate required rows - 0 if no events (will collapse) let maxRows = 0; - if (allDayEvents.length > 0) { - // Find the HIGHEST row number in use (not count of unique rows) + if (this.currentLayouts.length > 0) { + // Find the HIGHEST row number in use from currentLayouts let highestRow = 0; - (Array.from(allDayEvents) as HTMLElement[]).forEach((event: HTMLElement) => { - const gridRow = parseInt(event.style.gridRow) || 1; - highestRow = Math.max(highestRow, gridRow); + this.currentLayouts.forEach((layout) => { + highestRow = Math.max(highestRow, layout.row); }); // Max rows = highest row number (e.g. if row 3 is used, height = 3 rows) maxRows = highestRow; + console.log('🔍 AllDayManager: Height calculation using currentLayouts', { + totalLayouts: this.currentLayouts.length, + highestRowFound: highestRow, + maxRows + }); } // Store actual row count @@ -205,12 +202,17 @@ export class AllDayManager { // Show 4 rows when collapsed (3 events + indicators) if (!this.isExpanded) { + displayRows = this.MAX_COLLAPSED_ROWS; this.updateOverflowIndicators(); + } else { + this.clearOverflowIndicators(); + } } else { + // Hide chevron - not needed this.updateChevronButton(false); this.clearOverflowIndicators();