@@ -60,6 +60,13 @@ export interface DatePickerRangeProps extends DatePickerBaseProps {
6060 startDate ?: DateType ;
6161 endDate ?: DateType ;
6262 onChange ?: RangeChange ;
63+ /**
64+ * When `true`, tapping any date while a complete range (both startDate and
65+ * endDate) is selected will clear the endDate and begin a fresh selection
66+ * with the tapped date as the new startDate, regardless of whether the
67+ * tapped day falls inside the range, on the start, or on the end.
68+ */
69+ allowRangeReset ?: boolean ;
6370}
6471
6572export interface DatePickerMultipleProps extends DatePickerBaseProps {
@@ -117,6 +124,11 @@ const DateTimePicker = (
117124 use12Hours,
118125 } = props ;
119126
127+ const allowRangeReset =
128+ mode === 'range'
129+ ? ( props as DatePickerRangeProps ) . allowRangeReset
130+ : undefined ;
131+
120132 dayjs . tz . setDefault ( timeZone ) ;
121133 dayjs . calendar ( calendar ) ;
122134 dayjs . locale ( locale ) ;
@@ -385,6 +397,7 @@ const DateTimePicker = (
385397 prevTimezone ,
386398 timeZone ,
387399 calendar ,
400+ onChange ,
388401 ] ) ;
389402
390403 const setCalendarView = useCallback ( ( view : CalendarViews ) => {
@@ -412,6 +425,15 @@ const DateTimePicker = (
412425 let start = removeTime ( stateRef . current . startDate , timeZone ) ;
413426 let end = removeTime ( stateRef . current . endDate , timeZone ) ;
414427 const selected = removeTime ( selectedDate , timeZone ) ;
428+
429+ if ( allowRangeReset && start && end ) {
430+ ( onChange as RangeChange ) ( {
431+ startDate : dayjs ( selected ) . toDate ( ) ,
432+ endDate : undefined ,
433+ } ) ;
434+ return ;
435+ }
436+
415437 let isStart : boolean = true ;
416438 let isReset : boolean = false ;
417439
0 commit comments