Add undefined fallback for valueMonth state

Added else clauses to set valueMonth to undefined when month values are not provided:
- Prevents stale date values in calendar
- Ensures calendar displays correctly when switching between date ranges

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Jay Sheen
2025-10-31 18:43:07 +09:00
parent 6b9ee65418
commit 4e5e0a8760

View File

@@ -55,6 +55,8 @@ const NiceCalendarMonth = ({
if (startDate.isValid()) { if (startDate.isValid()) {
setValueMonth(startDate.toDate()); setValueMonth(startDate.toDate());
} }
} else {
setValueMonth(undefined);
} }
} }
else if(calendarType === CalendarType.End){ else if(calendarType === CalendarType.End){
@@ -71,6 +73,8 @@ const NiceCalendarMonth = ({
if (endDate.isValid()) { if (endDate.isValid()) {
setValueMonth(endDate.toDate()); setValueMonth(endDate.toDate());
} }
} else {
setValueMonth(undefined);
} }
} }
else if(calendarType === CalendarType.Single){ else if(calendarType === CalendarType.Single){
@@ -79,6 +83,8 @@ const NiceCalendarMonth = ({
if (singleDate.isValid()) { if (singleDate.isValid()) {
setValueMonth(singleDate.toDate()); setValueMonth(singleDate.toDate());
} }
} else {
setValueMonth(undefined);
} }
} }
}; };