File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed
packages/react-aria-components Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -1321,7 +1321,11 @@ export interface CellRenderProps {
13211321 /**
13221322 * The unique id of the cell.
13231323 **/
1324- id ?: Key
1324+ id ?: Key ,
1325+ /**
1326+ * The index of the cell within its row.
1327+ */
1328+ cellIndex : number
13251329}
13261330
13271331export interface CellProps extends RenderProps < CellRenderProps > , GlobalDOMAttributes < HTMLTableCellElement > {
Original file line number Diff line number Diff line change @@ -858,6 +858,31 @@ describe('Table', () => {
858858 expect ( cells [ 0 ] ) . toHaveTextContent ( 'Foo (focused)' ) ;
859859 } ) ;
860860
861+ it ( 'should support cell index in render props' , ( ) => {
862+ let { getAllByRole} = render (
863+ < Table aria-label = "Search results" >
864+ < TableHeader >
865+ < Column isRowHeader > Name</ Column >
866+ < Column isRowHeader > Type</ Column >
867+ </ TableHeader >
868+ < TableBody >
869+ < Row >
870+ < Cell >
871+ { ( { cellIndex} ) => `cell index: ${ cellIndex } ` }
872+ </ Cell >
873+ < Cell >
874+ { ( { cellIndex} ) => `cell index: ${ cellIndex } ` }
875+ </ Cell >
876+ </ Row >
877+ </ TableBody >
878+ </ Table >
879+ ) ;
880+
881+ let cells = getAllByRole ( 'rowheader' ) ;
882+ expect ( cells [ 0 ] ) . toHaveTextContent ( 'cell index: 0' ) ;
883+ expect ( cells [ 1 ] ) . toHaveTextContent ( 'cell index: 1' ) ;
884+ } ) ;
885+
861886 it ( 'should support columnHeader typeahead' , async ( ) => {
862887 let { getAllByRole} = render (
863888 < Table aria-label = "Files" >
You can’t perform that action at this time.
0 commit comments