@@ -996,6 +996,113 @@ describe("date field", () => {
996996 await expect . element ( t . month ) . toHaveTextContent ( "mm" ) ;
997997 await expect . element ( t . year ) . toHaveTextContent ( "yyyy" ) ;
998998 } ) ;
999+
1000+ it ( "should allow typing hours 0-23 with non en-US locales that use 24-hour format" , async ( ) => {
1001+ if ( navigator . userAgent . includes ( "WebKit" ) ) {
1002+ expect ( true ) ;
1003+ return ;
1004+ }
1005+
1006+ setup ( {
1007+ granularity : "minute" ,
1008+ locale : "de-DE" , // german uses 24-hour format
1009+ } ) ;
1010+
1011+ const { getHour } = getTimeSegments ( page . getByTestId ) ;
1012+ const hour = getHour ( ) ;
1013+
1014+ // should not have dayPeriod for 24-hour locales
1015+ await expectNotExists ( page . getByTestId ( "dayPeriod" ) ) ;
1016+
1017+ // test typing single digit hours > 2 (issue: these get clamped to 12-hour format)
1018+ await hour . click ( ) ;
1019+ await userEvent . keyboard ( "3" ) ;
1020+ await expect . element ( hour ) . toHaveTextContent ( "03" ) ;
1021+
1022+ // test typing hours 13-23 (issue: these should work but currently clamp)
1023+ await hour . click ( ) ;
1024+ await userEvent . keyboard ( "15" ) ;
1025+ await expect . element ( hour ) . toHaveTextContent ( "15" ) ;
1026+
1027+ await hour . click ( ) ;
1028+ await userEvent . keyboard ( "23" ) ;
1029+ await expect . element ( hour ) . toHaveTextContent ( "23" ) ;
1030+
1031+ await hour . click ( ) ;
1032+ await userEvent . keyboard ( "18" ) ;
1033+ await expect . element ( hour ) . toHaveTextContent ( "18" ) ;
1034+ } ) ;
1035+
1036+ it ( "should allow arrow key navigation through full 0-23 range with 24-hour locales" , async ( ) => {
1037+ if ( navigator . userAgent . includes ( "WebKit" ) ) {
1038+ expect ( true ) ;
1039+ return ;
1040+ }
1041+
1042+ const value = new CalendarDateTime ( 2023 , 10 , 12 , 14 , 30 , 30 , 0 ) ;
1043+ setup ( {
1044+ value,
1045+ granularity : "minute" ,
1046+ locale : "fr-FR" , // french uses 24-hour format
1047+ } ) ;
1048+
1049+ const { getHour } = getTimeSegments ( page . getByTestId ) ;
1050+ const hour = getHour ( ) ;
1051+
1052+ await expect . element ( hour ) . toHaveTextContent ( "14" ) ;
1053+
1054+ // arrow up should go to 15, not clamp to 12
1055+ await hour . click ( ) ;
1056+ await userEvent . keyboard ( kbd . ARROW_UP ) ;
1057+ await expect . element ( hour ) . toHaveTextContent ( "15" ) ;
1058+
1059+ // continue to 23
1060+ for ( let i = 0 ; i < 8 ; i ++ ) {
1061+ await userEvent . keyboard ( kbd . ARROW_UP ) ;
1062+ }
1063+ await expect . element ( hour ) . toHaveTextContent ( "23" ) ;
1064+
1065+ // arrow up from 23 should cycle to 00
1066+ await userEvent . keyboard ( kbd . ARROW_UP ) ;
1067+ await expect . element ( hour ) . toHaveTextContent ( "00" ) ;
1068+
1069+ // arrow down from 00 should go to 23
1070+ await userEvent . keyboard ( kbd . ARROW_DOWN ) ;
1071+ await expect . element ( hour ) . toHaveTextContent ( "23" ) ;
1072+ } ) ;
1073+
1074+ it ( "should display and allow typing hours > 12 with sv-SE locale (24-hour format)" , async ( ) => {
1075+ if ( navigator . userAgent . includes ( "WebKit" ) ) {
1076+ expect ( true ) ;
1077+ return ;
1078+ }
1079+
1080+ const value = new CalendarDateTime ( 2023 , 10 , 12 , 18 , 30 , 30 , 0 ) ;
1081+ setup ( {
1082+ value,
1083+ granularity : "minute" ,
1084+ locale : "sv-SE" , // swedish uses 24-hour format
1085+ } ) ;
1086+
1087+ const { getHour } = getTimeSegments ( page . getByTestId ) ;
1088+ const hour = getHour ( ) ;
1089+
1090+ // should display 18, not clamp to 12 or convert to 12-hour format
1091+ await expect . element ( hour ) . toHaveTextContent ( "18" ) ;
1092+
1093+ // should not have dayPeriod segment
1094+ await expectNotExists ( page . getByTestId ( "dayPeriod" ) ) ;
1095+
1096+ // typing should allow values > 12
1097+ await hour . click ( ) ;
1098+ await userEvent . keyboard ( "20" ) ;
1099+ await expect . element ( hour ) . toHaveTextContent ( "20" ) ;
1100+
1101+ // arrow down should work correctly (not clamp to 1-12 range)
1102+ await hour . click ( ) ;
1103+ await userEvent . keyboard ( kbd . ARROW_DOWN ) ;
1104+ await expect . element ( hour ) . toHaveTextContent ( "19" ) ;
1105+ } ) ;
9991106} ) ;
10001107
10011108/**
0 commit comments