Skip to content
This repository was archived by the owner on Jun 28, 2026. It is now read-only.

Commit c77b914

Browse files
authored
fix: onMonthChange inconsistent month value (#8204)
1 parent 6483ced commit c77b914

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

components/lib/calendar/Calendar.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -395,11 +395,11 @@ export const Calendar = React.memo(
395395

396396
newViewDate.setMonth(11);
397397
newViewDate.setFullYear(newYear);
398-
props.onMonthChange && props.onMonthChange({ month: 11, year: newYear });
398+
props.onMonthChange && props.onMonthChange({ month: 12, year: newYear });
399399
setCurrentMonth(11);
400400
} else {
401401
newViewDate.setMonth(newViewDate.getMonth() - 1);
402-
props.onMonthChange && props.onMonthChange({ month: currentMonth - 1, year: currentYear });
402+
props.onMonthChange && props.onMonthChange({ month: currentMonth, year: currentYear });
403403
setCurrentMonth((prevState) => prevState - 1);
404404
}
405405
} else if (currentView === 'month') {
@@ -444,11 +444,11 @@ export const Calendar = React.memo(
444444

445445
newViewDate.setMonth(0);
446446
newViewDate.setFullYear(newYear);
447-
props.onMonthChange && props.onMonthChange({ month: 0, year: newYear });
447+
props.onMonthChange && props.onMonthChange({ month: 1, year: newYear });
448448
setCurrentMonth(0);
449449
} else {
450450
newViewDate.setMonth(newViewDate.getMonth() + 1);
451-
props.onMonthChange && props.onMonthChange({ month: currentMonth + 1, year: currentYear });
451+
props.onMonthChange && props.onMonthChange({ month: currentMonth + 2, year: currentYear });
452452
setCurrentMonth((prevState) => prevState + 1);
453453
}
454454
} else if (currentView === 'month') {

0 commit comments

Comments
 (0)