From e0252c74b3b516ee5292356cad0d48b56f256e42 Mon Sep 17 00:00:00 2001 From: Michael Lee Date: Thu, 23 Jan 2025 08:17:10 -0600 Subject: [PATCH 1/3] Correct date handling for minDate in month selection --- packages/ui/src/components/Datepicker/Views/Months.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/ui/src/components/Datepicker/Views/Months.tsx b/packages/ui/src/components/Datepicker/Views/Months.tsx index 2faf45e37..8b51dc706 100644 --- a/packages/ui/src/components/Datepicker/Views/Months.tsx +++ b/packages/ui/src/components/Datepicker/Views/Months.tsx @@ -37,8 +37,10 @@ export const DatepickerViewsMonth: FC = ({ theme: cu
{[...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" }); From 020f781a27090738b5fe1a514add09c536baea5b Mon Sep 17 00:00:00 2001 From: Michael Lee Date: Thu, 23 Jan 2025 09:13:52 -0600 Subject: [PATCH 2/3] Add .changeset --- .changeset/proud-spoons-joke.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/proud-spoons-joke.md diff --git a/.changeset/proud-spoons-joke.md b/.changeset/proud-spoons-joke.md new file mode 100644 index 000000000..7bb474e78 --- /dev/null +++ b/.changeset/proud-spoons-joke.md @@ -0,0 +1,5 @@ +--- +"flowbite-react": major +--- + +Correct date handling for minDate in month selection From 0a3004c09434216867bdeef48b184a6d285d170b Mon Sep 17 00:00:00 2001 From: Michael Lee Date: Thu, 23 Jan 2025 09:18:31 -0600 Subject: [PATCH 3/3] Update .changeset --- .changeset/proud-spoons-joke.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.changeset/proud-spoons-joke.md b/.changeset/proud-spoons-joke.md index 7bb474e78..0625f9618 100644 --- a/.changeset/proud-spoons-joke.md +++ b/.changeset/proud-spoons-joke.md @@ -3,3 +3,13 @@ --- Correct date handling for minDate in month selection + +What's Changed + +- Fixed a bug where month selection wasn't respecting minDate constraints +- Month buttons are now correctly enabled/disabled based on minDate + +Impact + +- Users will see more accurate month selection behavior when minDate is set +- No breaking changes or migration steps required