Skip to content

Commit 50b8bd6

Browse files
fix: not allowing to select other year (themesberg#1465)
* fix: not allowing to select other year * prettier fix
1 parent c47d3a8 commit 50b8bd6

File tree

1 file changed

+11
-1
lines changed
  • packages/ui/src/components/Datepicker/Views

1 file changed

+11
-1
lines changed

packages/ui/src/components/Datepicker/Views/Months.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,16 @@ export interface DatepickerViewsMonthsProps {
2020
}
2121

2222
export const DatepickerViewsMonth: FC<DatepickerViewsMonthsProps> = ({ theme: customTheme = {} }) => {
23-
const { theme: rootTheme, minDate, maxDate, selectedDate, language, setViewDate, setView } = useDatePickerContext();
23+
const {
24+
theme: rootTheme,
25+
minDate,
26+
maxDate,
27+
selectedDate,
28+
viewDate,
29+
language,
30+
setViewDate,
31+
setView,
32+
} = useDatePickerContext();
2433

2534
const theme = mergeDeep(rootTheme.views.months, customTheme);
2635

@@ -30,6 +39,7 @@ export const DatepickerViewsMonth: FC<DatepickerViewsMonthsProps> = ({ theme: cu
3039
const newDate = new Date();
3140
// setting day to 1 to avoid overflow issues
3241
newDate.setMonth(index, 1);
42+
newDate.setFullYear(viewDate.getFullYear());
3343
const month = getFormattedDate(language, newDate, { month: "short" });
3444

3545
const isSelected = isMonthEqual(selectedDate, newDate);

0 commit comments

Comments
 (0)