Skip to content

Commit

Permalink
fix: not allowing to select other year (#1465)
Browse files Browse the repository at this point in the history
* fix: not allowing to select other year

* prettier fix
  • Loading branch information
khareemnurulla authored Aug 7, 2024
1 parent c47d3a8 commit 50b8bd6
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/ui/src/components/Datepicker/Views/Months.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,16 @@ export interface DatepickerViewsMonthsProps {
}

export const DatepickerViewsMonth: FC<DatepickerViewsMonthsProps> = ({ 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);

Expand All @@ -30,6 +39,7 @@ export const DatepickerViewsMonth: FC<DatepickerViewsMonthsProps> = ({ 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);
Expand Down

0 comments on commit 50b8bd6

Please sign in to comment.