@@ -20,6 +20,9 @@ import {
20
20
GridListItem ,
21
21
UNSTABLE_ListLayout as ListLayout ,
22
22
RouterProvider ,
23
+ Tag ,
24
+ TagGroup ,
25
+ TagList ,
23
26
useDragAndDrop ,
24
27
UNSTABLE_Virtualizer as Virtualizer
25
28
} from '../' ;
@@ -415,6 +418,46 @@ describe('GridList', () => {
415
418
expect ( rows . map ( r => r . textContent ) ) . toEqual ( [ 'Item 7' , 'Item 8' , 'Item 9' , 'Item 10' , 'Item 11' , 'Item 12' , 'Item 13' , 'Item 14' , 'Item 49' ] ) ;
416
419
} ) ;
417
420
421
+ it ( 'should support rendering a TagGroup inside a GridListItem' , async ( ) => {
422
+ let buttonRef = React . createRef ( ) ;
423
+ let { getAllByRole} = render (
424
+ < GridList aria-label = "Test" >
425
+ < GridListItem data-test-id = "grid-list" id = "tags" textValue = "tags" >
426
+ < TagGroup aria-label = "Tag group" >
427
+ < TagList >
428
+ < Tag key = "1" > Tag 1</ Tag >
429
+ < Tag key = "2" > Tag 2</ Tag >
430
+ < Tag key = "3" > Tag 3</ Tag >
431
+ </ TagList >
432
+ </ TagGroup >
433
+ </ GridListItem >
434
+ < GridListItem id = "dog" textValue = "Dog" > Dog < Button aria-label = "Info" ref = { buttonRef } > ⓘ</ Button > </ GridListItem >
435
+ < GridListItem id = "kangaroo" > Kangaroo</ GridListItem >
436
+ </ GridList >
437
+ ) ;
438
+
439
+ let items = getAllByRole ( 'grid' ) [ 0 ] . children ;
440
+ let tags = within ( items [ 0 ] ) . getAllByRole ( 'row' ) ;
441
+
442
+ await user . tab ( ) ;
443
+ expect ( document . activeElement ) . toBe ( items [ 0 ] ) ;
444
+
445
+ await user . keyboard ( '{ArrowRight}' ) ;
446
+ expect ( document . activeElement ) . toBe ( tags [ 0 ] ) ;
447
+
448
+ await user . keyboard ( '{ArrowRight}' ) ;
449
+ expect ( document . activeElement ) . toBe ( tags [ 1 ] ) ;
450
+
451
+ await user . keyboard ( '{ArrowDown}' ) ;
452
+ expect ( document . activeElement ) . toBe ( items [ 1 ] ) ;
453
+
454
+ await user . tab ( ) ;
455
+ expect ( document . activeElement ) . toBe ( buttonRef . current ) ;
456
+
457
+ await user . tab ( ) ;
458
+ expect ( document . activeElement ) . toBe ( document . body ) ;
459
+ } ) ;
460
+
418
461
describe ( 'drag and drop' , ( ) => {
419
462
it ( 'should support drag button slot' , ( ) => {
420
463
let { getAllByRole} = render ( < DraggableGridList /> ) ;
0 commit comments