Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DateRangePicker3 bug when initialMonth is equal to the maxDate's month #6548

Merged
Merged
Changes from all 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
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;
}
}