Disable month-scroll wheel navigation when event panel is open

Prevents accidental month changes (and lost edits) while scrolling
anywhere on the calendar page with the detail panel visible.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Kyle 2026-03-17 19:02:30 +08:00
parent 11f42ef91e
commit 43322db5ff

View File

@ -187,12 +187,13 @@ export default function CalendarPage() {
return () => cancelAnimationFrame(rafId); return () => cancelAnimationFrame(rafId);
}, [panelOpen]); }, [panelOpen]);
// Scroll wheel navigation in month view // Scroll wheel navigation in month view (disabled when detail panel is open)
useEffect(() => { useEffect(() => {
const el = calendarContainerRef.current; const el = calendarContainerRef.current;
if (!el) return; if (!el) return;
let debounceTimer: ReturnType<typeof setTimeout> | null = null; let debounceTimer: ReturnType<typeof setTimeout> | null = null;
const handleWheel = (e: WheelEvent) => { const handleWheel = (e: WheelEvent) => {
if (panelOpen) return;
// Skip wheel navigation on touch devices (let them scroll normally) // Skip wheel navigation on touch devices (let them scroll normally)
if ('ontouchstart' in window) return; if ('ontouchstart' in window) return;
const api = calendarRef.current?.getApi(); const api = calendarRef.current?.getApi();
@ -207,7 +208,7 @@ export default function CalendarPage() {
}; };
el.addEventListener('wheel', handleWheel, { passive: false }); el.addEventListener('wheel', handleWheel, { passive: false });
return () => el.removeEventListener('wheel', handleWheel); return () => el.removeEventListener('wheel', handleWheel);
}, []); }, [panelOpen]);
// AW-2: Track visible date range for scoped event fetching // AW-2: Track visible date range for scoped event fetching
// W-02 fix: Initialize from current month to avoid unscoped first fetch // W-02 fix: Initialize from current month to avoid unscoped first fetch