@@ -307,6 +307,62 @@ test.describe("datepicker [range]", () => {
307307 await I . seeInputHasValue ( "06/10/2024" , 0 )
308308 await I . seeInputHasValue ( "06/20/2024" , 1 )
309309 } )
310+
311+ test ( "Enter on a completed range starts a new range instead of keeping the old end" , async ( ) => {
312+ // create initial range
313+ await I . focusInput ( 0 )
314+ await I . type ( "06/10/2024" , 0 )
315+ await I . clickOutsideToBlur ( )
316+ await I . focusInput ( 1 )
317+ await I . type ( "06/20/2024" , 1 )
318+ await I . clickOutsideToBlur ( )
319+ await I . seeInputHasValue ( "06/10/2024" , 0 )
320+ await I . seeInputHasValue ( "06/20/2024" , 1 )
321+
322+ // reopen and pick a new date with the keyboard
323+ await I . clickTrigger ( )
324+ await I . seeContent ( )
325+ await I . seeDayCellIsFocused ( "2024-06-10" )
326+ await I . pressKey ( "ArrowRight" )
327+ await I . seeDayCellIsFocused ( "2024-06-11" )
328+ await I . pressKey ( "Enter" )
329+
330+ // should reset to a single new start, stay open and move to the next day
331+ await I . seeInputHasValue ( "06/11/2024" , 0 )
332+ await I . seeInputHasValue ( "" , 1 )
333+ await I . seeContent ( )
334+ await I . seeDayCellIsFocused ( "2024-06-12" )
335+ } )
336+
337+ test ( "selecting a range start with Enter previews the range band" , async ( ) => {
338+ await I . clickTrigger ( )
339+ await I . seeContent ( )
340+ await I . seeTodayCellIsFocused ( )
341+ await I . pressKey ( "Enter" )
342+ // the start is selected and the band previews to the next focused day, without moving first
343+ await expect ( I . todayCell ) . toHaveAttribute ( "data-range-start" , "" )
344+ await expect ( I . getNextDayCell ( ) ) . toHaveAttribute ( "data-in-hover-range" , "" )
345+ } )
346+
347+ test ( "reopening with only a start date resumes range selection" , async ( ) => {
348+ const start = I . getDate ( { day : 10 } )
349+ const end = I . getDate ( { day : 20 } )
350+
351+ // commit only a start date, then click outside
352+ await I . clickTrigger ( )
353+ await I . seeContent ( )
354+ await I . clickDayCell ( 10 )
355+ await I . clickOutsideToBlur ( )
356+ await I . seeInputHasValue ( start . formatted , 0 )
357+ await I . seeInputHasValue ( "" , 1 )
358+
359+ // reopening and picking another date should complete the range
360+ await I . clickTrigger ( )
361+ await I . seeContent ( )
362+ await I . clickDayCell ( 20 )
363+ await I . seeInputHasValue ( start . formatted , 0 )
364+ await I . seeInputHasValue ( end . formatted , 1 )
365+ } )
310366} )
311367
312368test . describe ( "datepicker [locale numerals]" , ( ) => {
0 commit comments