diff --git a/src/DataGrid.tsx b/src/DataGrid.tsx index f386331d0b..fd602f6b2f 100644 --- a/src/DataGrid.tsx +++ b/src/DataGrid.tsx @@ -698,6 +698,10 @@ function DataGrid( ); } + function getGridRowStart(rowIdx: number) { + return headerAndTopSummaryRowsCount + 1 + rowIdx; + } + function selectCell(position: Position, enableEditor?: Maybe): void { if (!isCellWithinSelectionBounds(position)) return; commitEditorChanges(); @@ -852,7 +856,7 @@ function DataGrid( return ( ( } const row = rows[rowIdx]; - const gridRowStart = headerAndTopSummaryRowsCount + rowIdx + 1; + const gridRowStart = getGridRowStart(rowIdx); let key: K | number = rowIdx; let isRowSelected = false; if (typeof rowKeyGetter === 'function') { @@ -980,7 +984,7 @@ function DataGrid( rowElements.push( renderRow(key, { // aria-rowindex is 1 based - 'aria-rowindex': headerAndTopSummaryRowsCount + rowIdx + 1, + 'aria-rowindex': gridRowStart, 'aria-selected': isSelectable ? isRowSelected : undefined, rowIdx, row, @@ -1137,8 +1141,8 @@ function DataGrid( })} {getViewportRows()} {bottomSummaryRows?.map((row, rowIdx) => { - const gridRowStart = headerAndTopSummaryRowsCount + rows.length + rowIdx + 1; const summaryRowIdx = rows.length + rowIdx; + const gridRowStart = getGridRowStart(summaryRowIdx); const isSummaryRowSelected = selectedPosition.rowIdx === summaryRowIdx; const top = clientHeight > totalRowHeight @@ -1190,7 +1194,7 @@ function DataGrid( [rowSelectedWithFrozenCell]: isGroupRowFocused && lastFrozenColumnIndex !== -1 })} style={{ - gridRowStart: selectedPosition.rowIdx + headerAndTopSummaryRowsCount + 1 + gridRowStart: getGridRowStart(selectedPosition.rowIdx) }} /> )}