Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Body/BodyRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface BodyRowProps<RecordType> {
onRow: GetComponentProps<RecordType>;
rowExpandable: (record: RecordType) => boolean;
indent?: number;
rowKey: React.Key;
getRowKey: GetRowKey<RecordType>;
childrenColumnName: string;
}
Expand All @@ -43,6 +44,7 @@ function BodyRow<RecordType extends { children?: RecordType[] }>(props: BodyRowP
stickyOffsets,
record,
index,
rowKey,
getRowKey,
rowExpandable,
onRow,
Expand Down Expand Up @@ -118,6 +120,7 @@ function BodyRow<RecordType extends { children?: RecordType[] }>(props: BodyRowP
const baseRowNode = (
<RowComponent
{...additionalProps}
data-row-key={rowKey}
className={classNames(
className,
`${prefixCls}-row`,
Expand Down
1 change: 1 addition & 0 deletions src/Body/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ function Body<RecordType>({
return [
<BodyRow
key={key}
rowKey={key}
record={record}
recordKey={key}
index={index}
Expand Down
17 changes: 17 additions & 0 deletions tests/Table.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -729,4 +729,21 @@ describe('Table.Basic', () => {
);
expect(wrapper.find('.test')).toHaveLength(1);
});

it('component body should pass `data-row-key`', () => {
const wrapper = mount(
<Table
columns={[{ dataIndex: 'test' }]}
components={{ body: { row: props => <tr {...props} /> } }}
data={[{ test: 'bamboo', key: 'light' }]}
/>,
);

expect(
wrapper
.find('tr')
.last()
.props()['data-row-key'],
).toEqual('light');
});
});
14 changes: 14 additions & 0 deletions tests/__snapshots__/ExpandRow.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ exports[`Table.Expand childrenColumnName 1`] = `
>
<tr
class="rc-table-row rc-table-row-level-0"
data-row-key="0"
>
<td
class="rc-table-cell rc-table-cell-with-append"
Expand All @@ -56,6 +57,7 @@ exports[`Table.Expand childrenColumnName 1`] = `
</tr>
<tr
class="rc-table-row rc-table-row-level-1"
data-row-key="0"
>
<td
class="rc-table-cell rc-table-cell-with-append"
Expand All @@ -76,6 +78,7 @@ exports[`Table.Expand childrenColumnName 1`] = `
</tr>
<tr
class="rc-table-row rc-table-row-level-0"
data-row-key="1"
>
<td
class="rc-table-cell rc-table-cell-with-append"
Expand Down Expand Up @@ -153,6 +156,7 @@ exports[`Table.Expand renders fixed column correctly work 1`] = `
>
<tr
class="rc-table-row rc-table-row-level-0"
data-row-key="0"
>
<td
class="rc-table-cell rc-table-row-expand-icon-cell rc-table-cell-fix-left"
Expand Down Expand Up @@ -199,6 +203,7 @@ exports[`Table.Expand renders fixed column correctly work 1`] = `
</tr>
<tr
class="rc-table-row rc-table-row-level-0"
data-row-key="1"
>
<td
class="rc-table-cell rc-table-row-expand-icon-cell rc-table-cell-fix-left"
Expand Down Expand Up @@ -286,6 +291,7 @@ exports[`Table.Expand renders tree row correctly 1`] = `
>
<tr
class="rc-table-row rc-table-row-level-0"
data-row-key="0"
>
<td
class="rc-table-cell rc-table-cell-with-append"
Expand All @@ -306,6 +312,7 @@ exports[`Table.Expand renders tree row correctly 1`] = `
</tr>
<tr
class="rc-table-row rc-table-row-level-1"
data-row-key="0"
>
<td
class="rc-table-cell rc-table-cell-with-append"
Expand All @@ -326,6 +333,7 @@ exports[`Table.Expand renders tree row correctly 1`] = `
</tr>
<tr
class="rc-table-row rc-table-row-level-0"
data-row-key="1"
>
<td
class="rc-table-cell rc-table-cell-with-append"
Expand Down Expand Up @@ -387,6 +395,7 @@ exports[`Table.Expand renders tree row correctly with different children 1`] = `
>
<tr
class="rc-table-row rc-table-row-level-0"
data-row-key="0"
>
<td
class="rc-table-cell rc-table-cell-with-append"
Expand All @@ -407,6 +416,7 @@ exports[`Table.Expand renders tree row correctly with different children 1`] = `
</tr>
<tr
class="rc-table-row rc-table-row-level-0"
data-row-key="1"
>
<td
class="rc-table-cell rc-table-cell-with-append"
Expand All @@ -427,6 +437,7 @@ exports[`Table.Expand renders tree row correctly with different children 1`] = `
</tr>
<tr
class="rc-table-row rc-table-row-level-0"
data-row-key="2"
>
<td
class="rc-table-cell rc-table-cell-with-append"
Expand All @@ -447,6 +458,7 @@ exports[`Table.Expand renders tree row correctly with different children 1`] = `
</tr>
<tr
class="rc-table-row rc-table-row-level-0"
data-row-key="3"
>
<td
class="rc-table-cell rc-table-cell-with-append"
Expand All @@ -467,6 +479,7 @@ exports[`Table.Expand renders tree row correctly with different children 1`] = `
</tr>
<tr
class="rc-table-row rc-table-row-level-0"
data-row-key="4"
>
<td
class="rc-table-cell rc-table-cell-with-append"
Expand All @@ -487,6 +500,7 @@ exports[`Table.Expand renders tree row correctly with different children 1`] = `
</tr>
<tr
class="rc-table-row rc-table-row-level-0"
data-row-key="5"
>
<td
class="rc-table-cell rc-table-cell-with-append"
Expand Down
18 changes: 18 additions & 0 deletions tests/__snapshots__/FixedColumn.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ exports[`Table.FixedColumn renders correctly scrollX - with data 1`] = `
>
<tr
class="rc-table-row rc-table-row-level-0"
data-row-key="1"
>
<td
class="rc-table-cell rc-table-cell-fix-left"
Expand Down Expand Up @@ -171,6 +172,7 @@ exports[`Table.FixedColumn renders correctly scrollX - with data 1`] = `
</tr>
<tr
class="rc-table-row rc-table-row-level-0"
data-row-key="2"
>
<td
class="rc-table-cell rc-table-cell-fix-left"
Expand Down Expand Up @@ -236,6 +238,7 @@ exports[`Table.FixedColumn renders correctly scrollX - with data 1`] = `
</tr>
<tr
class="rc-table-row rc-table-row-level-0"
data-row-key="3"
>
<td
class="rc-table-cell rc-table-cell-fix-left"
Expand Down Expand Up @@ -283,6 +286,7 @@ exports[`Table.FixedColumn renders correctly scrollX - with data 1`] = `
</tr>
<tr
class="rc-table-row rc-table-row-level-0"
data-row-key="4"
>
<td
class="rc-table-cell rc-table-cell-fix-left"
Expand Down Expand Up @@ -330,6 +334,7 @@ exports[`Table.FixedColumn renders correctly scrollX - with data 1`] = `
</tr>
<tr
class="rc-table-row rc-table-row-level-0"
data-row-key="5"
>
<td
class="rc-table-cell rc-table-cell-fix-left"
Expand Down Expand Up @@ -377,6 +382,7 @@ exports[`Table.FixedColumn renders correctly scrollX - with data 1`] = `
</tr>
<tr
class="rc-table-row rc-table-row-level-0"
data-row-key="6"
>
<td
class="rc-table-cell rc-table-cell-fix-left"
Expand Down Expand Up @@ -424,6 +430,7 @@ exports[`Table.FixedColumn renders correctly scrollX - with data 1`] = `
</tr>
<tr
class="rc-table-row rc-table-row-level-0"
data-row-key="7"
>
<td
class="rc-table-cell rc-table-cell-fix-left"
Expand Down Expand Up @@ -471,6 +478,7 @@ exports[`Table.FixedColumn renders correctly scrollX - with data 1`] = `
</tr>
<tr
class="rc-table-row rc-table-row-level-0"
data-row-key="8"
>
<td
class="rc-table-cell rc-table-cell-fix-left"
Expand Down Expand Up @@ -518,6 +526,7 @@ exports[`Table.FixedColumn renders correctly scrollX - with data 1`] = `
</tr>
<tr
class="rc-table-row rc-table-row-level-0"
data-row-key="9"
>
<td
class="rc-table-cell rc-table-cell-fix-left"
Expand Down Expand Up @@ -834,6 +843,7 @@ exports[`Table.FixedColumn renders correctly scrollXY - with data 1`] = `
>
<tr
class="rc-table-row rc-table-row-level-0"
data-row-key="1"
>
<td
class="rc-table-cell rc-table-cell-fix-left"
Expand Down Expand Up @@ -899,6 +909,7 @@ exports[`Table.FixedColumn renders correctly scrollXY - with data 1`] = `
</tr>
<tr
class="rc-table-row rc-table-row-level-0"
data-row-key="2"
>
<td
class="rc-table-cell rc-table-cell-fix-left"
Expand Down Expand Up @@ -964,6 +975,7 @@ exports[`Table.FixedColumn renders correctly scrollXY - with data 1`] = `
</tr>
<tr
class="rc-table-row rc-table-row-level-0"
data-row-key="3"
>
<td
class="rc-table-cell rc-table-cell-fix-left"
Expand Down Expand Up @@ -1011,6 +1023,7 @@ exports[`Table.FixedColumn renders correctly scrollXY - with data 1`] = `
</tr>
<tr
class="rc-table-row rc-table-row-level-0"
data-row-key="4"
>
<td
class="rc-table-cell rc-table-cell-fix-left"
Expand Down Expand Up @@ -1058,6 +1071,7 @@ exports[`Table.FixedColumn renders correctly scrollXY - with data 1`] = `
</tr>
<tr
class="rc-table-row rc-table-row-level-0"
data-row-key="5"
>
<td
class="rc-table-cell rc-table-cell-fix-left"
Expand Down Expand Up @@ -1105,6 +1119,7 @@ exports[`Table.FixedColumn renders correctly scrollXY - with data 1`] = `
</tr>
<tr
class="rc-table-row rc-table-row-level-0"
data-row-key="6"
>
<td
class="rc-table-cell rc-table-cell-fix-left"
Expand Down Expand Up @@ -1152,6 +1167,7 @@ exports[`Table.FixedColumn renders correctly scrollXY - with data 1`] = `
</tr>
<tr
class="rc-table-row rc-table-row-level-0"
data-row-key="7"
>
<td
class="rc-table-cell rc-table-cell-fix-left"
Expand Down Expand Up @@ -1199,6 +1215,7 @@ exports[`Table.FixedColumn renders correctly scrollXY - with data 1`] = `
</tr>
<tr
class="rc-table-row rc-table-row-level-0"
data-row-key="8"
>
<td
class="rc-table-cell rc-table-cell-fix-left"
Expand Down Expand Up @@ -1246,6 +1263,7 @@ exports[`Table.FixedColumn renders correctly scrollXY - with data 1`] = `
</tr>
<tr
class="rc-table-row rc-table-row-level-0"
data-row-key="9"
>
<td
class="rc-table-cell rc-table-cell-fix-left"
Expand Down
Loading