diff --git a/packages/ui/src/components/Datepicker/Views/Months.tsx b/packages/ui/src/components/Datepicker/Views/Months.tsx
index 30fbe4d679..46b3172bed 100644
--- a/packages/ui/src/components/Datepicker/Views/Months.tsx
+++ b/packages/ui/src/components/Datepicker/Views/Months.tsx
@@ -33,8 +33,9 @@ export function DatepickerViewsMonth() {
{[...Array(12)].map((_month, index) => {
const newDate = new Date();
- // setting day to 1 to avoid overflow issues
- newDate.setMonth(index, 1);
+ // if selectedDate is non-null, align days to accurately detect if month is selected
+ // else if selectedDate is null, set day to 1 to avoid overflow
+ newDate.setMonth(index, selectedDate ? selectedDate.getDate() : 1);
newDate.setFullYear(viewDate.getFullYear());
const month = getFormattedDate(language, newDate, { month: "short" });