@@ -253,6 +253,49 @@ test('keyboard navigation works',
253253 } ,
254254)
255255
256+ test ( 'keyboard navigation works when first option has null as value' ,
257+ [ html `
258+ < main x-data ="{ active: null } ">
259+ < div x-radio x-model ="active ">
260+ < div x-radio:option option ="option-null " :value ="null "> </ div >
261+ < div x-radio:option option ="option-1 " value ="1 "> </ div >
262+ < div x-radio:option option ="option-2 " value ="2 "> </ div >
263+ </ div >
264+
265+ < input x-model ="active " type ="hidden ">
266+ </ main >
267+ ` ] ,
268+ ( { get } ) => {
269+ get ( '[option="option-1"]' ) . focus ( ) . type ( '{downarrow}' )
270+ get ( '[option="option-2"]' ) . should ( haveFocus ( ) ) . type ( '{uparrow}' )
271+ get ( '[option="option-1"]' ) . should ( haveFocus ( ) ) . type ( '{uparrow}' )
272+ get ( '[option="option-null"]' ) . should ( haveFocus ( ) ) . type ( '{uparrow}' )
273+ get ( '[option="option-2"]' ) . should ( haveFocus ( ) ) . type ( '{downarrow}' )
274+ get ( '[option="option-null"]' ) . should ( haveFocus ( ) )
275+ } ,
276+ )
277+
278+ test ( 'keyboard navigation works when last option has null as value' ,
279+ [ html `
280+ < main x-data ="{ active: null } ">
281+ < div x-radio x-model ="active ">
282+ < div x-radio:option option ="option-1 " value ="1 "> </ div >
283+ < div x-radio:option option ="option-2 " value ="2 "> </ div >
284+ < div x-radio:option option ="option-null " :value ="null "> </ div >
285+ </ div >
286+
287+ < input x-model ="active " type ="hidden ">
288+ </ main >
289+ ` ] ,
290+ ( { get } ) => {
291+ get ( '[option="option-1"]' ) . focus ( ) . type ( '{downarrow}' )
292+ get ( '[option="option-2"]' ) . should ( haveFocus ( ) ) . type ( '{downarrow}' )
293+ get ( '[option="option-null"]' ) . should ( haveFocus ( ) ) . type ( '{downarrow}' )
294+ get ( '[option="option-1"]' ) . should ( haveFocus ( ) ) . type ( '{uparrow}' )
295+ get ( '[option="option-null"]' ) . should ( haveFocus ( ) )
296+ } ,
297+ )
298+
256299test ( 'has accessibility attributes' ,
257300 [ html `
258301 < main x-data ="{ active: null, access: [
0 commit comments