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:
parent
cf463cc691
commit
c7b9abde9a
1 changed files with 14 additions and 12 deletions
|
|
@ -169,28 +169,25 @@ export class AllDayManager {
|
||||||
* Check current all-day events and animate to correct height
|
* Check current all-day events and animate to correct height
|
||||||
*/
|
*/
|
||||||
public checkAndAnimateAllDayHeight(): void {
|
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)
|
// Calculate required rows - 0 if no events (will collapse)
|
||||||
let maxRows = 0;
|
let maxRows = 0;
|
||||||
|
|
||||||
if (allDayEvents.length > 0) {
|
if (this.currentLayouts.length > 0) {
|
||||||
// Find the HIGHEST row number in use (not count of unique rows)
|
// Find the HIGHEST row number in use from currentLayouts
|
||||||
let highestRow = 0;
|
let highestRow = 0;
|
||||||
|
|
||||||
(Array.from(allDayEvents) as HTMLElement[]).forEach((event: HTMLElement) => {
|
this.currentLayouts.forEach((layout) => {
|
||||||
const gridRow = parseInt(event.style.gridRow) || 1;
|
highestRow = Math.max(highestRow, layout.row);
|
||||||
highestRow = Math.max(highestRow, gridRow);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Max rows = highest row number (e.g. if row 3 is used, height = 3 rows)
|
// Max rows = highest row number (e.g. if row 3 is used, height = 3 rows)
|
||||||
maxRows = highestRow;
|
maxRows = highestRow;
|
||||||
|
|
||||||
|
console.log('🔍 AllDayManager: Height calculation using currentLayouts', {
|
||||||
|
totalLayouts: this.currentLayouts.length,
|
||||||
|
highestRowFound: highestRow,
|
||||||
|
maxRows
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store actual row count
|
// Store actual row count
|
||||||
|
|
@ -205,12 +202,17 @@ export class AllDayManager {
|
||||||
|
|
||||||
// Show 4 rows when collapsed (3 events + indicators)
|
// Show 4 rows when collapsed (3 events + indicators)
|
||||||
if (!this.isExpanded) {
|
if (!this.isExpanded) {
|
||||||
|
|
||||||
displayRows = this.MAX_COLLAPSED_ROWS;
|
displayRows = this.MAX_COLLAPSED_ROWS;
|
||||||
this.updateOverflowIndicators();
|
this.updateOverflowIndicators();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
this.clearOverflowIndicators();
|
this.clearOverflowIndicators();
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Hide chevron - not needed
|
// Hide chevron - not needed
|
||||||
this.updateChevronButton(false);
|
this.updateChevronButton(false);
|
||||||
this.clearOverflowIndicators();
|
this.clearOverflowIndicators();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue