palantir / blueprint

A React-based UI toolkit for the web
https://blueprintjs.com/
Apache License 2.0
20.51k stars 2.15k forks source link

Picking a second time for a single day changes the date #6863

Open evansjohnson opened 6 days ago

evansjohnson commented 6 days ago

Environment

Code Sandbox

Link to a minimal repro - can see it in the docs

Steps to reproduce

  1. Enable the time picker (doesn't matter if allowSingleDayRange is on or off)
  2. Click on a single day in the DateRangePicker3
  3. Change its end time

Actual behavior

The second date in the range becomes today's date at the time you selected

Expected behavior

The second date in the range becomes the date you selected at the time you selected. Also, the selection highlighting sometimes looks wrong - the whole month has the pale blue selection and all of the dates in between the date you selected and the current day are dark blue.

Possible solution

The second date in the range is treated as null when only one date has been clicked (or if allowSingleDayRange is on, when only one date has been clicked one time -- if you click it a second time this behavior does not occur). The TimePicker then attempts to modify a null date, so it falls back to today's date based on this line of code. I think changing this so it does something like "grab the date at the other index if this one is null but the time isn't null" would fix it.