@@ -7,9 +7,10 @@ interface UpdatedCellProptypes {
77 onKeyDown ?: KeyboardEventHandler < HTMLDivElement > ;
88 'aria-expanded' ?: string ;
99 'aria-label' ?: string ;
10- 'aria-colindex' ?: number ;
11- 'aria-describedby' ?: string ;
12- role ?: string ;
10+ 'aria-colindex' : number ;
11+ 'aria-describedby' : string ;
12+ 'aria-labelledby' : string ;
13+ role : string ;
1314}
1415
1516const setCellProps = ( cellProps , { cell, instance } : { cell : TableInstance [ 'cell' ] ; instance : TableInstance } ) => {
@@ -22,8 +23,8 @@ const setCellProps = (cellProps, { cell, instance }: { cell: TableInstance['cell
2223 'aria-colindex' : columnIndex + 1 ,
2324 role : 'gridcell' ,
2425 // header label
25- 'aria-describedby' : ` ${ uniqueId } ${ column . id } ` ,
26- 'aria-label ' : '' ,
26+ 'aria-describedby' : '' ,
27+ 'aria-labelledby ' : ` ${ uniqueId } ${ column . id } ${ uniqueId } ${ column . id } ${ row . id } ` ,
2728 } ;
2829
2930 const RowSubComponent = typeof renderRowSubComponent === 'function' ? renderRowSubComponent ( row ) : undefined ;
@@ -38,7 +39,6 @@ const setCellProps = (cellProps, { cell, instance }: { cell: TableInstance['cell
3839
3940 const isFirstUserCol = userCols [ 0 ] ?. id === column . id || userCols [ 0 ] ?. accessor === column . accessor ;
4041 updatedCellProps [ 'data-is-first-column' ] = isFirstUserCol ;
41- updatedCellProps [ 'aria-label' ] += value || value === 0 ? `${ value } ` : '' ;
4242
4343 if ( ( isFirstUserCol && rowIsExpandable ) || ( row . isGrouped && row . canExpand ) ) {
4444 updatedCellProps . onKeyDown = row . getToggleRowExpandedProps ?.( ) ?. onKeyDown ;
@@ -65,11 +65,13 @@ const setCellProps = (cellProps, { cell, instance }: { cell: TableInstance['cell
6565 }
6666 const { cellLabel } = cell . column ;
6767 if ( typeof cellLabel === 'function' ) {
68- cell . cellLabel = '' ;
68+ const cellHeaderLabel = column . headerLabel || ( typeof column . Header === 'string' ? column . Header : '' ) ;
69+ const cellValueLabel = value || value === 0 ? `${ value } ` : '' ;
70+ cell . cellLabel = `${ cellHeaderLabel } ${ cellValueLabel } ` ;
6971 updatedCellProps [ 'aria-label' ] = cellLabel ( { cell, instance } ) ;
70- } else {
71- updatedCellProps [ 'aria-label' ] ||= undefined ;
72+ updatedCellProps [ 'aria-labelledby' ] = undefined ;
7273 }
74+
7375 return [ cellProps , updatedCellProps ] ;
7476} ;
7577
0 commit comments