Clear mini calendar selection on main calendar navigation

Clicking Today/prev/next on the toolbar now clears the selected day
in the mini calendar, so only the today highlight remains visible.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Kyle 2026-03-17 20:08:56 +08:00
parent 2d76ecf869
commit bda02039a6

View File

@ -44,14 +44,15 @@ const MiniCalendar = memo(function MiniCalendar({
); );
const [selectedDate, setSelectedDate] = useState<string | null>(null); const [selectedDate, setSelectedDate] = useState<string | null>(null);
// Sync displayed month when main calendar navigates across months // Sync displayed month when main calendar navigates (toolbar prev/next/today)
// selectedDate is only set by user clicks in the mini calendar, not by external navigation // Also clear selected date — avoids stale highlight after "Today" click
useEffect(() => { useEffect(() => {
if (!currentDate) return; if (!currentDate) return;
const incoming = startOfMonth(parseDate(currentDate)); const incoming = startOfMonth(parseDate(currentDate));
setDisplayedMonth((prev) => setDisplayedMonth((prev) =>
prev.getTime() === incoming.getTime() ? prev : incoming prev.getTime() === incoming.getTime() ? prev : incoming
); );
setSelectedDate(null);
}, [currentDate, parseDate]); }, [currentDate, parseDate]);
const days = useMemo( const days = useMemo(