Skip to content

RangeCalendar: option to start a new range on click once a range is complete #82609

Closed

Description

@retrofox

What problem does this address?

RangeCalendar always adjusts a complete range on click. With Aug 12 – Aug 24 selected, clicking Aug 3 gives Aug 3 – Aug 24 and clicking Aug 20 gives Aug 12 – Aug 20 (react-day-picker's addToRange). The hover preview in usePreviewRange draws the dashed outline for that same move-the-nearest-end intent.

Many range pickers follow the other convention: the first click starts a range, the second completes it, and the next click starts a new range. A consumer can implement that on top of a controlled value and onValueChange's triggerDate, but the hover preview keeps drawing the adjust intent and there is no way to align it. RangeCalendar sets modifiers, modifiersClassNames, onDayMouseEnter / onDayMouseLeave and components after spreading the consumer props, so none of them can be overridden. The calendar then previews one range and the click produces another.

What is your proposed solution?

Let RangeCalendar own the selection behaviour, for example a prop like selectionBehavior?: 'adjust' | 'restart', defaulting to 'adjust' (the current behaviour):

  • 'restart': when value already has both ends, a click sets value to { from: triggerDate }; the next click completes the range, ordering the two days.
  • The hover preview follows the mode. With a complete range in 'restart' mode, hovering previews only the hovered day as the next start (the single-day dashed outline usePreviewRange already draws when min / max cannot be met). With a half-open range it previews from → hovered, as today.

A smaller first step would be a way to opt out of, or override, the built-in preview, so a consumer-side selection model can keep the visuals consistent.

Happy to open a PR once the API direction is agreed.

Step-by-step reproduction instructions

  1. Open the RangeCalendar story.
  2. Click two days to select a range.
  3. Hover a day before the range: the dashed outline runs from that day to the range start.
  4. Click it: the range is extended to that day. There is no way to make this click start a new range, or to make the preview say so.

Activity

  1. added
    [Type] Enhancement
    [Package] UI
    on Sep 8, 2026
  2. self-assigned this
    on Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

[Package] UI[Type] Enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions