Skip to content

Commit

Permalink
[datetime2] fix(DateRangePicker3): left/right month display (#6548)
Browse files Browse the repository at this point in the history
Fix DateRangePicker3 bug when initialMonth is equal to the maxDate's month
  • Loading branch information
mattskrobola authored and adidahiya committed Nov 15, 2023
1 parent 256f711 commit 6fbe319
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,17 @@ function getInitialMonth(props: DateRangePicker3Props, value: DateRange): Date {
}
return month;
} else if (DateUtils.isDayInRange(today, [props.minDate!, props.maxDate!])) {
if (!isSingleMonthOnly && DateUtils.isSameMonth(today, props.maxDate!)) {
// special case: if today is in the maxDate month, display it on the right calendar
today.setMonth(today.getMonth() - 1);
}
return today;
} else {
return DateUtils.getDateBetween([props.minDate!, props.maxDate!]);
const betweenDate = DateUtils.getDateBetween([props.minDate!, props.maxDate!]);
if (!isSingleMonthOnly && DateUtils.isSameMonth(betweenDate, props.maxDate!)) {
// special case: if betweenDate is in the maxDate month, display it on the right calendar
betweenDate.setMonth(betweenDate.getMonth() - 1);
}
return betweenDate;
}
}

0 comments on commit 6fbe319

Please sign in to comment.