@@ -22,7 +22,7 @@ export const A11yMixin = (superClass) =>
2222 } ;
2323 }
2424 static get observers ( ) {
25- return [ '_a11yUpdateGridSize(size, _columnTree)' ] ;
25+ return [ '_a11yUpdateGridSize(size, _columnTree, __emptyState )' ] ;
2626 }
2727
2828 /** @private */
@@ -34,21 +34,27 @@ export const A11yMixin = (superClass) =>
3434
3535 /** @private */
3636 _a11yGetFooterRowCount ( _columnTree ) {
37- return _columnTree . filter ( ( level ) => level . some ( ( col ) => col . headerRenderer ) ) . length ;
37+ return _columnTree . filter ( ( level ) => level . some ( ( col ) => col . footerRenderer ) ) . length ;
3838 }
3939
4040 /** @private */
41- _a11yUpdateGridSize ( size , _columnTree ) {
41+ _a11yUpdateGridSize ( size , _columnTree , emptyState ) {
4242 if ( size === undefined || _columnTree === undefined ) {
4343 return ;
4444 }
4545
46+ const headerRowsCount = this . _a11yGetHeaderRowCount ( _columnTree ) ;
47+ const footerRowsCount = this . _a11yGetFooterRowCount ( _columnTree ) ;
48+ const bodyRowsCount = emptyState ? 1 : size ;
49+ const rowsCount = bodyRowsCount + headerRowsCount + footerRowsCount ;
50+
51+ this . $ . table . setAttribute ( 'aria-rowcount' , rowsCount ) ;
52+
4653 const bodyColumns = _columnTree [ _columnTree . length - 1 ] ;
47- this . $ . table . setAttribute (
48- 'aria-rowcount' ,
49- size + this . _a11yGetHeaderRowCount ( _columnTree ) + this . _a11yGetFooterRowCount ( _columnTree ) ,
50- ) ;
51- this . $ . table . setAttribute ( 'aria-colcount' , ( bodyColumns && bodyColumns . length ) || 0 ) ;
54+ // If no header and footer rows while the empty state is active, count as one column
55+ // Otherwise, use the number of body columns, if present
56+ const columnsCount = emptyState ? 1 : ( rowsCount && bodyColumns && bodyColumns . length ) || 0 ;
57+ this . $ . table . setAttribute ( 'aria-colcount' , columnsCount ) ;
5258
5359 this . _a11yUpdateHeaderRows ( ) ;
5460 this . _a11yUpdateFooterRows ( ) ;
0 commit comments