Skip to content

Commit 3f93293

Browse files
author
Lydia HE (HTX)
committed
Fixed DatePicker month view error: selected month not highlighted
1 parent 2dcc282 commit 3f93293

File tree

1 file changed

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

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ export function DatepickerViewsMonth() {
3333
<div className={theme.items.base}>
3434
{[...Array(12)].map((_month, index) => {
3535
const newDate = new Date();
36-
// setting day to 1 to avoid overflow issues
37-
newDate.setMonth(index, 1);
36+
// if selectedDate is non-null, align days to accurately detect if month is selected
37+
// else if selectedDate is null, set day to 1 to avoid overflow
38+
newDate.setMonth(index, selectedDate ? selectedDate.getDate() : 1);
3839
newDate.setFullYear(viewDate.getFullYear());
3940
const month = getFormattedDate(language, newDate, { month: "short" });
4041

0 commit comments

Comments
 (0)