Skip to content

Cannot select time when selectsRange prop is true #4649

@yubinjodev

Description

@yubinjodev

Describe the bug
When selectsRange is true, selecting the date along with time causes a type error. Just selecting the dates does not.

To Reproduce
Steps to reproduce the behavior:

  const [startDate, setStartDate] = useState<Date | null>(null)
  const [endDate, setEndDate] = useState<Date | null>(null)

  const handleChange = ([newStartDate, newEndDate]:[Date, Date]) => {
    setStartDate(newStartDate);
    setEndDate(newEndDate);
  };

  return (
    <DatePicker
        selected={startDate}
        onChange={handleChange}
        selectsRange
        startDate={startDate}
        endDate={endDate}
        dateFormat="yyyy-MM-dd HH:mm:ss"
        timeFormat="HH:mm:ss"
        showTimeSelect
    />
  );

  1. Select date
  2. Select time

Expected behavior
I expected that I could select a range that includes both date and time

Screenshots
image

Desktop (please complete the following information):

  • OS: macOS
  • Browser: Chrome
  • Version: 123.0.6312.87

Smartphone (please complete the following information):
None

Additional context
None

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions