Hacker0x01 / react-datepicker

A simple and reusable datepicker component for React
https://reactdatepicker.com/
MIT License
8.09k stars 2.24k forks source link

Wrong returned date when minDate and showTimeSelect are given #3643

Open daweto opened 2 years ago

daweto commented 2 years ago

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:

  1. Create a DatePicker with a minDate set to the future and showTimeSelect
  2. Open the DatePicker and just select the time.
  3. 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: ss1

After selecting just the time: ss2

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

shreekeshmurkar commented 2 years ago

@dweinstein1 This can be easily solved by passing same value to both, minDate and selected, properties.

cm-sdpick commented 2 years ago

@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.

cm-sdpick commented 2 years ago

I found another work-around for the case where isClearable is set true - just set openToDate and minDate to the same value.

github-actions[bot] commented 4 months ago

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 10 days.