-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
The "previous month" button appears when selecting a date #5193
Comments
This seems to fix the issue. Basically the current code relies on the date selected. However if multiple calendars are selected then it doesn't know if the min month is rendered. Borrowed some code from So the fix is likely to consider which was the 0th calendar rendered by applying the same math. (i.e. if the first month calendar is October and the selected date is in November, then we need to subtract 1 to ensure we're checking the correct date. not creating a PR because tests (even on a clean checkout) aren't passing for me. diff --git a/src/calendar.tsx b/src/calendar.tsx
index 461e1c81..799de807 100644
--- a/src/calendar.tsx
+++ b/src/calendar.tsx
@@ -543,7 +543,17 @@ export default class Calendar extends Component<CalendarProps, CalendarState> {
);
break;
default:
- allPrevDaysDisabled = monthDisabledBefore(this.state.date, this.props);
+ const monthsShown =
+ this.props.monthsShown ?? Calendar.defaultProps.monthsShown;
+ const monthsToSubtract = this.props.showPreviousMonths
+ ? monthsShown - 1
+ : 0;
+
+ const monthSelectedIn = this.props.monthSelectedIn ?? monthsToSubtract;
+ const fromMonthDate = subMonths(this.state.date, monthSelectedIn);
+
+ allPrevDaysDisabled = monthDisabledBefore(fromMonthDate, this.props);
+
break;
} |
@pmacmillan You just have to move all the variable declarations out of |
Please do! |
Describe the bug
The "previous month" button appears when selecting a date
To Reproduce
Steps to reproduce the behavior:
Expected behavior
the "previous month" button does not appear because the calendar starts in October
Additional context
Add any other context about the problem here.
v.6.9.0 also reproduced in 7.4.0
The text was updated successfully, but these errors were encountered: