Skip to content

DateRangePicker: time-picker changes can emit reverse-ordered ranges #8122

@vhellem

Description

@vhellem

Feature request

DateRangePicker is obviously a component mean to have chronologically ordered time selection.

the boundaryToModify prop documentation states this explicitly:

▎ This will be honored unless the next click would overlap the other boundary date. In that case, the two boundary dates will be auto-swapped to keep them in chronological order.

However, the same invariant is not enforced when the user changes a boundary via its TimePicker. With timePrecision set, each boundary has an independent TimePicker; changing the left (start) time to be later than the right (end) time emits [laterDate, earlierDate] from onChange with no normalization.

The two paths diverge in dateRangePicker.tsx:

  • Day-click path (handleDayMouseEnter / handleNextState) normalizes via DateUtils.getDateTime + boundary swap logic.
  • Time-picker path (handleTimeChange, ~lines 176–186 in v6.0.25) writes the new boundary at dateIndex and immediately calls onChange without ordering the resulting [Date, Date]:

Examples

  1. Open https://blueprintjs.com/docs/#datetime/date-range-picker
  2. Check allow single day range
  3. Select the same day
  4. Manually edit the before time to be later than the after time

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions