Skip to content

Commit

Permalink
Update disable prev and next state on month and year change
Browse files Browse the repository at this point in the history
  • Loading branch information
guidosreis committed Dec 13, 2021
1 parent 9494adb commit bcb781b
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/components/DayPickerRangeController.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,13 @@ export default class DayPickerRangeController extends React.PureComponent {
}

onMonthChange(newMonth) {
const { numberOfMonths, enableOutsideDays, orientation } = this.props;
const {
enableOutsideDays,
maxDate,
minDate,
numberOfMonths,
orientation,
} = this.props;
const withoutTransitionMonths = orientation === VERTICAL_SCROLLABLE;
const newVisibleDays = getVisibleDays(
newMonth,
Expand All @@ -983,11 +989,19 @@ export default class DayPickerRangeController extends React.PureComponent {
this.setState({
currentMonth: newMonth.clone(),
visibleDays: this.getModifiers(newVisibleDays),
disablePrev: this.shouldDisableMonthNavigation(minDate, newMonth),
disableNext: this.shouldDisableMonthNavigation(maxDate, newMonth),
});
}

onYearChange(newMonth) {
const { numberOfMonths, enableOutsideDays, orientation } = this.props;
const {
enableOutsideDays,
maxDate,
minDate,
numberOfMonths,
orientation,
} = this.props;
const withoutTransitionMonths = orientation === VERTICAL_SCROLLABLE;
const newVisibleDays = getVisibleDays(
newMonth,
Expand All @@ -999,6 +1013,8 @@ export default class DayPickerRangeController extends React.PureComponent {
this.setState({
currentMonth: newMonth.clone(),
visibleDays: this.getModifiers(newVisibleDays),
disablePrev: this.shouldDisableMonthNavigation(minDate, newMonth),
disableNext: this.shouldDisableMonthNavigation(maxDate, newMonth),
});
}

Expand Down

0 comments on commit bcb781b

Please sign in to comment.