-
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
showPreviousMonths={true} is not working properly #4023
Comments
<DatePicker
|
same issue too |
Any update on this? Its super broken |
No, we couldn't fix it. |
Ok I actually was able to hack my way around this issue with something like the following: const START_OF_LAST_MONTH = startOfMonth(subMonths(new Date(), 1));
const [startDate, setStartDate] = useState(START_OF_LAST_MONTH);
const [initialized, setInitialized] = useState(false);
useEffect(
function clearPreviousMonthStartDate() {
if (!initialized) {
setStartDate(null);
setInitialized(true);
}
return function resetInitializedState() {
setInitialized(false);
};
},
[startDate, initialized]
);
return (
<DatePicker
fixedHeight
open
onChange={([start, end]) => {
setStartDate(start);
setEndDate(end);
}}
monthsShown={2}
inline
selectsRange
startDate={startDate}
endDate={endDate}
maxDate={maximumDate}
minDate={minimumDate}
renderDayContents={renderCustomDayContents}
disabledKeyboardNavigation
/>
); This will render the picker with the visual appearance of what |
You can see this issue in action on the "Show previous month" example found on the demo website https://reactdatepicker.com/
What happens?
If you have showPreviousMonths={true} and you click any day it will jump to the previous month instead. This also applies to different cases such as implementations with selectsRange={true} and monthsShown={2}.
The text was updated successfully, but these errors were encountered: