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:
parent
2d76ecf869
commit
bda02039a6
@ -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(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user