@@ -387,13 +387,81 @@ describe('ListView', function () {
387387 expect ( rows [ 2 ] ) . toHaveAttribute ( 'aria-selected' , 'true' ) ;
388388 } ) ;
389389
390- it ( 'should support single tap to perform row selection with screen reader if onAction isn\'t provided' , function ( ) {
390+ it ( 'should toggle items in selection highlight with ctrl-click on Mac' , function ( ) {
391+ let uaMock = jest . spyOn ( navigator , 'platform' , 'get' ) . mockImplementation ( ( ) => 'Mac' ) ;
391392 let onSelectionChange = jest . fn ( ) ;
392393 let tree = renderSelectionList ( { onSelectionChange, selectionMode : 'multiple' , selectionStyle : 'highlight' } ) ;
393394
394395 let rows = tree . getAllByRole ( 'row' ) ;
395396 expect ( rows [ 1 ] ) . toHaveAttribute ( 'aria-selected' , 'false' ) ;
397+ expect ( rows [ 2 ] ) . toHaveAttribute ( 'aria-selected' , 'false' ) ;
398+ act ( ( ) => userEvent . click ( getCell ( tree , 'Bar' ) , { ctrlKey : true } ) ) ;
396399
400+ checkSelection ( onSelectionChange , [ 'bar' ] ) ;
401+ expect ( rows [ 1 ] ) . toHaveAttribute ( 'aria-selected' , 'true' ) ;
402+
403+ onSelectionChange . mockClear ( ) ;
404+ act ( ( ) => userEvent . click ( getCell ( tree , 'Baz' ) , { ctrlKey : true } ) ) ;
405+ checkSelection ( onSelectionChange , [ 'baz' ] ) ;
406+ expect ( rows [ 1 ] ) . toHaveAttribute ( 'aria-selected' , 'false' ) ;
407+ expect ( rows [ 2 ] ) . toHaveAttribute ( 'aria-selected' , 'true' ) ;
408+
409+ uaMock . mockRestore ( ) ;
410+ } ) ;
411+
412+ it ( 'should allow multiple items to be selected in selection highlight with ctrl-click on Windows' , function ( ) {
413+ let uaMock = jest . spyOn ( navigator , 'userAgent' , 'get' ) . mockImplementation ( ( ) => 'Windows' ) ;
414+ let onSelectionChange = jest . fn ( ) ;
415+ let tree = renderSelectionList ( { onSelectionChange, selectionMode : 'multiple' , selectionStyle : 'highlight' } ) ;
416+
417+ let rows = tree . getAllByRole ( 'row' ) ;
418+ expect ( rows [ 0 ] ) . toHaveAttribute ( 'aria-selected' , 'false' ) ;
419+ expect ( rows [ 1 ] ) . toHaveAttribute ( 'aria-selected' , 'false' ) ;
420+ expect ( rows [ 2 ] ) . toHaveAttribute ( 'aria-selected' , 'false' ) ;
421+ act ( ( ) => userEvent . click ( getCell ( tree , 'Foo' ) , { ctrlKey : true } ) ) ;
422+
423+ checkSelection ( onSelectionChange , [ 'foo' ] ) ;
424+ expect ( rows [ 0 ] ) . toHaveAttribute ( 'aria-selected' , 'true' ) ;
425+
426+ onSelectionChange . mockClear ( ) ;
427+ act ( ( ) => userEvent . click ( getCell ( tree , 'Baz' ) , { ctrlKey : true } ) ) ;
428+ checkSelection ( onSelectionChange , [ 'foo' , 'baz' ] ) ;
429+ expect ( rows [ 0 ] ) . toHaveAttribute ( 'aria-selected' , 'true' ) ;
430+ expect ( rows [ 1 ] ) . toHaveAttribute ( 'aria-selected' , 'false' ) ;
431+ expect ( rows [ 2 ] ) . toHaveAttribute ( 'aria-selected' , 'true' ) ;
432+
433+ uaMock . mockRestore ( ) ;
434+ } ) ;
435+
436+ it ( 'should toggle items in selection highlight with meta-click on Windows' , function ( ) {
437+ let uaMock = jest . spyOn ( navigator , 'userAgent' , 'get' ) . mockImplementation ( ( ) => 'Windows' ) ;
438+ let onSelectionChange = jest . fn ( ) ;
439+ let tree = renderSelectionList ( { onSelectionChange, selectionMode : 'multiple' , selectionStyle : 'highlight' } ) ;
440+
441+ let rows = tree . getAllByRole ( 'row' ) ;
442+ expect ( rows [ 1 ] ) . toHaveAttribute ( 'aria-selected' , 'false' ) ;
443+ expect ( rows [ 2 ] ) . toHaveAttribute ( 'aria-selected' , 'false' ) ;
444+ act ( ( ) => userEvent . click ( getCell ( tree , 'Bar' ) , { metaKey : true } ) ) ;
445+
446+ checkSelection ( onSelectionChange , [ 'bar' ] ) ;
447+ expect ( rows [ 1 ] ) . toHaveAttribute ( 'aria-selected' , 'true' ) ;
448+
449+ onSelectionChange . mockClear ( ) ;
450+ act ( ( ) => userEvent . click ( getCell ( tree , 'Baz' ) , { metaKey : true } ) ) ;
451+ checkSelection ( onSelectionChange , [ 'baz' ] ) ;
452+ expect ( rows [ 1 ] ) . toHaveAttribute ( 'aria-selected' , 'false' ) ;
453+ expect ( rows [ 2 ] ) . toHaveAttribute ( 'aria-selected' , 'true' ) ;
454+
455+ uaMock . mockRestore ( ) ;
456+ } ) ;
457+
458+ it ( 'should support single tap to perform row selection with screen reader if onAction isn\'t provided' , function ( ) {
459+ let onSelectionChange = jest . fn ( ) ;
460+ let tree = renderSelectionList ( { onSelectionChange, selectionMode : 'multiple' , selectionStyle : 'highlight' } ) ;
461+
462+ let rows = tree . getAllByRole ( 'row' ) ;
463+ expect ( rows [ 1 ] ) . toHaveAttribute ( 'aria-selected' , 'false' ) ;
464+
397465 act ( ( ) => userEvent . click ( within ( rows [ 1 ] ) . getByText ( 'Bar' ) , { pointerType : 'touch' , width : 0 , height : 0 } ) ) ;
398466 checkSelection ( onSelectionChange , [
399467 'bar'
0 commit comments