react-datepicker icon indicating copy to clipboard operation
react-datepicker copied to clipboard

selectsRange with showTimeInput shows only one time input

Open orelHAnyvision opened this issue 2 years ago • 2 comments

Describe the bug

trying to have selection of range with time, have only 1 time selection

To Reproduce

use this code snippet:

const NewDatePicker = () => {
  const [dateRange, setDateRange] = useState([null, null])
  const [startDate, endDate] = dateRange

  const ExampleCustomInput = forwardRef(({ value, onClick }, ref) => (
    <button className='example-custom-input' onClick={onClick} ref={ref}>
      {value}
    </button>
  ))

  return (
      <DatePicker
        selected={startDate}
        onChange={update => {
          const isDateUpdate = Array.isArray(update)
          setDateRange(isDateUpdate? update: [update, endDate])
        }}
        startDate={startDate}
        endDate={endDate}
        selectsRange
        monthsShown={2}
        customInput={<ExampleCustomInput />}
        dateFormat='mm/dd/yyyy hh:mm'
        showTimeInput
      />
  )
}

Expected behavior

have selection of times for both start and end dates

Desktop

  • OS: mac
  • Browser: chrome

orelHAnyvision avatar Jun 21 '22 08:06 orelHAnyvision

Same. Any updates on this?

standbyoneself avatar Sep 01 '22 12:09 standbyoneself