@@ -4,7 +4,7 @@ import TableCell from './TableCell';
44import TableCellCheckbox from './TableCellCheckbox' ;
55import TableCellExpander from './TableCellExpander' ;
66import ExpanderRow from './ExpanderRow' ;
7- import { equalizeId , getConditionalStyle , isOdd , noop } from './util' ;
7+ import { prop , equalizeId , getConditionalStyle , isOdd , noop } from './util' ;
88import { STOP_PROP_TAG } from './constants' ;
99import { TableRow , SingleRowAction , TableProps } from './types' ;
1010
@@ -90,7 +90,7 @@ interface TableRowProps<T> extends Required<DProps<T>> {
9090 onDragLeave : ( e : React . DragEvent < HTMLDivElement > ) => void ;
9191}
9292
93- function Row < T extends TableRow > ( {
93+ function Row < T > ( {
9494 columns = [ ] ,
9595 conditionalRowStyles = [ ] ,
9696 defaultExpanded = false ,
@@ -169,6 +169,7 @@ function Row<T extends TableRow>({
169169 [ defaultExpanderDisabled , expandOnRowDoubleClicked , expandableRows , handleExpanded , onRowDoubleClicked , row ] ,
170170 ) ;
171171
172+ const rowKeyField = prop ( row as TableRow , keyField ) ;
172173 const { style, classNames } = getConditionalStyle ( row , conditionalRowStyles , [ 'rdt_TableRow' ] ) ;
173174 const highlightSelected = selectableRowsHighlight && selected ;
174175 const inheritStyles = expandableInheritConditionalStyles ? style : { } ;
@@ -191,6 +192,7 @@ function Row<T extends TableRow>({
191192 >
192193 { selectableRows && (
193194 < TableCellCheckbox
195+ name = { `select-row-${ rowKeyField } ` }
194196 keyField = { keyField }
195197 row = { row }
196198 rowCount = { rowCount }
@@ -205,7 +207,7 @@ function Row<T extends TableRow>({
205207
206208 { expandableRows && ! expandableRowsHideExpander && (
207209 < TableCellExpander
208- id = { row [ keyField ] as string }
210+ id = { rowKeyField as string }
209211 expandableIcon = { expandableIcon }
210212 expanded = { expanded }
211213 row = { row }
@@ -221,8 +223,8 @@ function Row<T extends TableRow>({
221223
222224 return (
223225 < TableCell
224- id = { `cell-${ column . id } -${ row [ keyField ] } ` }
225- key = { `cell-${ column . id } -${ row [ keyField ] } ` }
226+ id = { `cell-${ column . id } -${ rowKeyField } ` }
227+ key = { `cell-${ column . id } -${ rowKeyField } ` }
226228 // apply a tag that Row will use to stop event propagation when TableCell is clicked
227229 dataTag = { column . ignoreRowClick || column . button ? null : STOP_PROP_TAG }
228230 column = { column }
@@ -241,7 +243,7 @@ function Row<T extends TableRow>({
241243
242244 { expandableRows && expanded && (
243245 < ExpanderRow
244- key = { `expander-${ row [ keyField ] } ` }
246+ key = { `expander-${ rowKeyField } ` }
245247 data = { row }
246248 extendedRowStyle = { inheritStyles }
247249 extendedClassNames = { classNames }
0 commit comments