diff --git a/packages/ui/src/components/Datepicker/Views/Months.tsx b/packages/ui/src/components/Datepicker/Views/Months.tsx index dcd98108f..3930638ba 100644 --- a/packages/ui/src/components/Datepicker/Views/Months.tsx +++ b/packages/ui/src/components/Datepicker/Views/Months.tsx @@ -20,7 +20,16 @@ export interface DatepickerViewsMonthsProps { } export const DatepickerViewsMonth: FC = ({ theme: customTheme = {} }) => { - const { theme: rootTheme, minDate, maxDate, selectedDate, language, setViewDate, setView } = useDatePickerContext(); + const { + theme: rootTheme, + minDate, + maxDate, + selectedDate, + viewDate, + language, + setViewDate, + setView, + } = useDatePickerContext(); const theme = mergeDeep(rootTheme.views.months, customTheme); @@ -30,6 +39,7 @@ export const DatepickerViewsMonth: FC = ({ theme: cu const newDate = new Date(); // setting day to 1 to avoid overflow issues newDate.setMonth(index, 1); + newDate.setFullYear(viewDate.getFullYear()); const month = getFormattedDate(language, newDate, { month: "short" }); const isSelected = isMonthEqual(selectedDate, newDate);