Optimizes header event handling and all-day display

Improves performance by early-exiting header event processing when no drag operation is active.
Ensures the all-day container height is re-evaluated after the mouse leaves the header area, maintaining correct layout.
This commit is contained in:
Janus C. H. Knudsen 2025-09-18 19:26:00 +02:00
parent 3b75e1cafc
commit 1538e8c460
2 changed files with 14 additions and 8 deletions

View file

@ -51,6 +51,12 @@ export class AllDayManager {
console.log('🏗️ AllDayManager: Received request to ensure all-day container exists');
this.ensureAllDayContainer();
});
// Listen for header mouseleave to recalculate all-day container height
eventBus.on('header:mouseleave', () => {
console.log('🔄 AllDayManager: Received header:mouseleave, recalculating height');
this.checkAndAnimateAllDayHeight();
});
}
/**

View file

@ -55,6 +55,14 @@ export class HeaderManager {
// Use mouseenter instead of mouseover to avoid continuous firing
this.headerEventListener = (event: Event) => {
// OPTIMIZED: Check for active drag operation FIRST before doing any other work
const isDragActive = document.querySelector('.dragging') !== null;
if (!isDragActive) {
// Ingen drag operation, spring resten af funktionen over
return;
}
const target = event.target as HTMLElement;
console.log('🖱️ HeaderManager: mouseenter detected on:', target.tagName, target.className);
@ -74,14 +82,6 @@ export class HeaderManager {
}
if (allDayContainer) {
// SMART CHECK: Only calculate target date if there's an active drag operation
const isDragActive = document.querySelector('.dragging') !== null;
if (!isDragActive) {
console.log('⏭️ HeaderManager: No active drag operation, skipping target date calculation');
return;
}
console.log('📍 HeaderManager: Active drag detected, calculating target date...');
// Calculate target date from mouse X coordinate