Skip to content

Correct date handling for minDate in month selection #1525

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/ui/src/components/Datepicker/Views/Months.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ export const DatepickerViewsMonth: FC<DatepickerViewsMonthsProps> = ({ theme: cu
<div className={theme.items.base}>
{[...Array(12)].map((_month, index) => {
const newDate = new Date();
// setting day to 1 to avoid overflow issues
newDate.setMonth(index, 1);
// Set newDate to the last day of the month based on the provided index.
// This is necessary for enabling the month button when minDate is set (e.g., minDate = 1/23/2025).
newDate.setMonth(index + 1, 1);
newDate.setDate(newDate.getDate() - 1);
newDate.setFullYear(viewDate.getFullYear());
const month = getFormattedDate(language, newDate, { month: "short" });

Expand Down