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.
This commit is contained in:
Janus C. H. Knudsen 2025-09-30 22:49:16 +02:00
parent cf463cc691
commit c7b9abde9a

View file

@ -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();