Skip to content

Commit e0252c7

Browse files
committed
Correct date handling for minDate in month selection
1 parent bed3c41 commit e0252c7

File tree

1 file changed

+4
-2
lines changed
  • packages/ui/src/components/Datepicker/Views

1 file changed

+4
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ export const DatepickerViewsMonth: FC<DatepickerViewsMonthsProps> = ({ theme: cu
3737
<div className={theme.items.base}>
3838
{[...Array(12)].map((_month, index) => {
3939
const newDate = new Date();
40-
// setting day to 1 to avoid overflow issues
41-
newDate.setMonth(index, 1);
40+
// Set newDate to the last day of the month based on the provided index.
41+
// This is necessary for enabling the month button when minDate is set (e.g., minDate = 1/23/2025).
42+
newDate.setMonth(index + 1, 1);
43+
newDate.setDate(newDate.getDate() - 1);
4244
newDate.setFullYear(viewDate.getFullYear());
4345
const month = getFormattedDate(language, newDate, { month: "short" });
4446

0 commit comments

Comments
 (0)