Enhances header drawer behavior during drag operations

Adds expanded state tracking for header drawer during drag
Ensures drawer remains in the correct expanded/collapsed state based on initial condition

Improves user experience by maintaining consistent drawer state
This commit is contained in:
Janus C. H. Knudsen 2025-12-10 23:31:07 +01:00
parent 6723658fd9
commit 679580702b

View file

@ -1,6 +1,7 @@
import { IEventBus } from '../../types/CalendarTypes'; import { IEventBus } from '../../types/CalendarTypes';
import { IGridConfig } from '../../core/IGridConfig'; import { IGridConfig } from '../../core/IGridConfig';
import { CoreEvents } from '../../constants/CoreEvents'; import { CoreEvents } from '../../constants/CoreEvents';
import { HeaderDrawerManager } from '../../core/HeaderDrawerManager';
import { import {
IDragEnterHeaderPayload, IDragEnterHeaderPayload,
IDragMoveHeaderPayload, IDragMoveHeaderPayload,
@ -20,10 +21,12 @@ export class HeaderDrawerRenderer {
private currentItem: HTMLElement | null = null; private currentItem: HTMLElement | null = null;
private container: HTMLElement | null = null; private container: HTMLElement | null = null;
private sourceElement: HTMLElement | null = null; private sourceElement: HTMLElement | null = null;
private wasExpandedBeforeDrag = false;
constructor( constructor(
private eventBus: IEventBus, private eventBus: IEventBus,
private gridConfig: IGridConfig private gridConfig: IGridConfig,
private headerDrawerManager: HeaderDrawerManager
) { ) {
this.setupListeners(); this.setupListeners();
} }
@ -63,6 +66,12 @@ export class HeaderDrawerRenderer {
this.container = document.querySelector('swp-header-drawer'); this.container = document.querySelector('swp-header-drawer');
if (!this.container) return; if (!this.container) return;
// Remember if drawer was already expanded
this.wasExpandedBeforeDrag = this.headerDrawerManager.isExpanded();
// Expand drawer with animation
this.headerDrawerManager.expand();
// Store reference to source element // Store reference to source element
this.sourceElement = payload.element; this.sourceElement = payload.element;
@ -147,5 +156,10 @@ export class HeaderDrawerRenderer {
this.sourceElement.style.visibility = ''; this.sourceElement.style.visibility = '';
this.sourceElement = null; this.sourceElement = null;
} }
// Collapse drawer if it wasn't expanded before drag
if (!this.wasExpandedBeforeDrag) {
this.headerDrawerManager.collapse();
}
} }
} }