react-datepicker
react-datepicker copied to clipboard
Wrong returned date when minDate and showTimeSelect are given
Describe the bug
If a minDate
on the future is given and also showTimeSelect
is set to true
, the calendar will open on the minDate
but when selecting time, the returned value will be the current date with the time selected, not the minDate
with the time selected as one would think because when opening the calendar, the minDate
was selected.
To Reproduce Steps to reproduce the behavior:
- Create a
DatePicker
with aminDate
set to the future andshowTimeSelect
- Open the
DatePicker
and just select the time. - The returned date will be the current date plus the selected time.
Expected behavior A clear and concise description of what you expected to happen.
When opening the DatePicker
and just selecting the time, it should return the minDate
plus the selectedTime
.
Screenshots
Opening the calendar:
After selecting just the time:
Desktop (please complete the following information):
- OS: macOS
- Browser: chrome, edge.
- Version: Chrome version 101.0.4951.67, Edge 101.0.1210.53
Additional context Add any other context about the problem here.
@dweinstein1 This can be easily solved by passing same value to both, minDate
and selected
, properties.
@shreekeshmurkar this is not possible to do when using the isClearable
prop, so the work-around doesn't work for me. When using isClearable={true}
selected
needs to be able to be set null
in order to clear the value.
I found another work-around for the case where isClearable
is set true
- just set openToDate
and minDate
to the same value.