-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
Describe the bug
I've noticed a strange behavior, which feels like a bug, but i may just be missing something. After clearing out a selected date range on the date-picker, the dates shown when opening the date-picker are different than the first time the date-picker was opened.
To Reproduce
Steps to reproduce the behavior:
- Go to 'docs page'
- Replace any of the examples with the sample code below
- Open the date-picker and choose any date range on the right-side calendar
- Clear the date range using the "X" button
- Open the date-picker again
() => {
const [startDate, setStartDate] = useState(null);
const [endDate, setEndDate] = useState(null);
const onChange = React.useCallback((dates) => {
setStartDate(dates[0]);
setEndDate(dates[1]);
}, [])
return (
<DatePicker
endDate={endDate}
isClearable
minDate={new Date()}
monthsShown={2}
onChange={onChange}
selected={startDate}
selectsRange
startDate={startDate}
/>
);
};
Expected behavior
I don't expect the previous month to show up on the left side, since the entire month is disabled. I would expect that the first month to show up on the left, should be the current month. This is how the date-picker behaves on the first-render before clearing the dates
Actual behavior
The previous month shows up on the left side, even though all dates in that month are disabled. And additionally, this behavior is different from the first time the date-picker is opened, where the left-side month is the current month.
Desktop (please complete the following information):
- OS: osx
- Browser: chrome
- Version: whichever version is running on the docs page - I presume the latest. I am also seeing this in V4.8.0 locally
Additional context
I have tried adding showPreviousMonths={false} but it makes no difference.

