You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
RangeCalendar: option to start a new range on click once a range is complete #82609
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.
Activity