@@ -263,6 +263,8 @@ function RangerPicker<DateType>() {
263
263
const needConfirmButton = computed (
264
264
( ) => ( props . picker === 'date' && ! ! props . showTime ) || props . picker === 'time' ,
265
265
) ;
266
+
267
+ const isDoubleClickRef = ref ( false ) ;
266
268
const presets = computed ( ( ) => props . presets ) ;
267
269
const ranges = computed ( ( ) => props . ranges ) ;
268
270
const presetList = usePresets ( presets , ranges ) ;
@@ -970,10 +972,30 @@ function RangerPicker<DateType>() {
970
972
971
973
const onContextSelect = ( date : DateType , type : 'key' | 'mouse' | 'submit' ) => {
972
974
const values = updateValues ( selectedValue . value , date , mergedActivePickerIndex . value ) ;
975
+ const currentIndex = mergedActivePickerIndex . value ;
976
+ const isDoubleClick = isDoubleClickRef . value ;
977
+ const shouldSwitch = type === 'mouse' && needConfirmButton . value && isDoubleClick ;
978
+
979
+ // Reset double click state
980
+ isDoubleClickRef . value = false ;
973
981
974
- if ( type === 'submit' || ( type !== 'key' && ! needConfirmButton . value ) ) {
982
+ if ( type === 'submit' || ( type !== 'key' && ! needConfirmButton . value ) || shouldSwitch ) {
975
983
// triggerChange will also update selected values
976
984
triggerChange ( values , mergedActivePickerIndex . value ) ;
985
+
986
+ // If double click, switch to next input
987
+ // But check if both inputs are complete, if so don't switch to avoid animation before popup closes
988
+ if ( shouldSwitch ) {
989
+ const startValue = getValue ( values , 0 ) ;
990
+ const endValue = getValue ( values , 1 ) ;
991
+ const bothValuesComplete = startValue && endValue ;
992
+
993
+ if ( ! bothValuesComplete ) {
994
+ const nextIndex = ( ( currentIndex + 1 ) % 2 ) as 0 | 1 ;
995
+ setMergedActivePickerIndex ( nextIndex ) ;
996
+ }
997
+ }
998
+
977
999
// clear hover value style
978
1000
if ( mergedActivePickerIndex . value === 0 ) {
979
1001
onStartLeave ( ) ;
@@ -993,6 +1015,7 @@ function RangerPicker<DateType>() {
993
1015
hideRanges : computed ( ( ) => true ) ,
994
1016
onSelect : onContextSelect ,
995
1017
open : mergedOpen ,
1018
+ isDoubleClickRef,
996
1019
} ) ;
997
1020
998
1021
return ( ) => {
0 commit comments