Skip to content
This repository was archived by the owner on May 19, 2025. It is now read-only.

Commit d26037c

Browse files
authored
Merge pull request #399 from everaldo/master
Fix bug of calendar not moving to previous months when selecting a preset range of 90 days and the currentFocusedDate is in the right side of the calendar.
2 parents b8eb288 + b1ae783 commit d26037c

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/utils.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
startOfWeek,
88
endOfWeek,
99
differenceInCalendarDays,
10+
differenceInCalendarMonths,
1011
addDays,
1112
} from 'date-fns';
1213

@@ -35,11 +36,7 @@ export function calcFocusDate(currentFocusedDate, props) {
3536

3637
// // just return targetDate for native scrolled calendars
3738
// if (props.scroll.enabled) return targetDate;
38-
const currentFocusInterval = {
39-
start: startOfMonth(currentFocusedDate),
40-
end: endOfMonth(addMonths(currentFocusedDate, months - 1)),
41-
};
42-
if (areIntervalsOverlapping(targetInterval, currentFocusInterval)) {
39+
if (differenceInCalendarMonths(targetInterval.start, targetInterval.end) > months) {
4340
// don't change focused if new selection in view area
4441
return currentFocusedDate;
4542
}

0 commit comments

Comments
 (0)