Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
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
5 changes: 5 additions & 0 deletions .changeset/proud-spoons-joke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"flowbite-react": major
---

Correct date handling for minDate in month selection
Comment on lines +4 to +5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Enhance the release notes with more details.

For better maintainability and user communication, please expand the release notes to include:

  • A detailed description of the bug that was fixed
  • The impact on users
  • Any changes in behavior they should expect

Example format:

 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
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Correct date handling for minDate in month selection
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

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