@@ -815,6 +815,66 @@ describe('Table', () => {
815815 expect ( cells [ 0 ] ) . toHaveTextContent ( 'Foo (focused)' ) ;
816816 } ) ;
817817
818+ it ( 'should support columnHeader typeahead' , async ( ) => {
819+ let { getAllByRole} = render (
820+ < Table aria-label = "Files" >
821+ < MyTableHeader columns = { columns } >
822+ { column => (
823+ < MyColumn isRowHeader = { column . isRowHeader } childColumns = { column . children } >
824+ { column . name }
825+ </ MyColumn >
826+ ) }
827+ </ MyTableHeader >
828+ < TableBody items = { rows } >
829+ { item => (
830+ < MyRow columns = { columns } >
831+ { column => < Cell > { item [ column . id ] } </ Cell > }
832+ </ MyRow >
833+ ) }
834+ </ TableBody >
835+ </ Table >
836+ ) ;
837+ let rowElements = getAllByRole ( 'row' ) ;
838+
839+ await user . tab ( ) ;
840+ expect ( document . activeElement ) . toBe ( rowElements [ 1 ] ) ;
841+ await user . keyboard ( 'boo' ) ;
842+ expect ( document . activeElement ) . toBe ( rowElements [ 3 ] ) ;
843+ } ) ;
844+
845+ it ( 'should support textValue overriding typeahead' , async ( ) => {
846+ let rows = [
847+ { id : 1 , name : '1. Games' , date : '6/7/2020' , type : 'File folder' , textValue : 'Games' } ,
848+ { id : 2 , name : '2. Program Files' , date : '4/7/2021' , type : 'File folder' , textValue : 'Program Files' } ,
849+ { id : 3 , name : '3. bootmgr' , date : '11/20/2010' , type : 'System file' , textValue : 'bootmgr' } ,
850+ { id : 4 , name : '4. log.txt' , date : '1/18/2016' , type : 'Text Document' , textValue : 'log.txt' }
851+ ] ;
852+ let { getAllByRole} = render (
853+ < Table aria-label = "Files" >
854+ < MyTableHeader columns = { columns } >
855+ { column => (
856+ < MyColumn isRowHeader = { column . isRowHeader } childColumns = { column . children } >
857+ { column . name }
858+ </ MyColumn >
859+ ) }
860+ </ MyTableHeader >
861+ < TableBody items = { rows } >
862+ { item => (
863+ < MyRow columns = { columns } textValue = { item . textValue } >
864+ { column => < Cell > { item [ column . id ] } </ Cell > }
865+ </ MyRow >
866+ ) }
867+ </ TableBody >
868+ </ Table >
869+ ) ;
870+ let rowElements = getAllByRole ( 'row' ) ;
871+
872+ await user . tab ( ) ;
873+ expect ( document . activeElement ) . toBe ( rowElements [ 1 ] ) ;
874+ await user . keyboard ( 'boo' ) ;
875+ expect ( document . activeElement ) . toBe ( rowElements [ 3 ] ) ;
876+ } ) ;
877+
818878 it ( 'should support updating columns' , ( ) => {
819879 let tree = render ( < DynamicTable tableHeaderProps = { { columns} } tableBodyProps = { { dependencies : [ columns ] } } rowProps = { { columns} } /> ) ;
820880 let headers = tree . getAllByRole ( 'columnheader' ) ;
@@ -929,7 +989,7 @@ describe('Table', () => {
929989 }
930990 }
931991 } ) ;
932-
992+
933993 describe ( 'colSpan' , ( ) => {
934994 it ( 'should render table with colSpans' , ( ) => {
935995 let { getAllByRole} = render ( < TableCellColSpan /> ) ;
0 commit comments