From d74b445dc8c8156c3eb238fc84ae626e6504e2bd Mon Sep 17 00:00:00 2001 From: zombiej Date: Tue, 14 Jan 2020 14:48:57 +0800 Subject: [PATCH 1/2] body add missing data-row-key --- src/Body/BodyRow.tsx | 3 +++ src/Body/index.tsx | 1 + 2 files changed, 4 insertions(+) diff --git a/src/Body/BodyRow.tsx b/src/Body/BodyRow.tsx index 946685c07..15fa35fbb 100644 --- a/src/Body/BodyRow.tsx +++ b/src/Body/BodyRow.tsx @@ -32,6 +32,7 @@ export interface BodyRowProps { onRow: GetComponentProps; rowExpandable: (record: RecordType) => boolean; indent?: number; + rowKey: React.Key; getRowKey: GetRowKey; childrenColumnName: string; } @@ -43,6 +44,7 @@ function BodyRow(props: BodyRowP stickyOffsets, record, index, + rowKey, getRowKey, rowExpandable, onRow, @@ -118,6 +120,7 @@ function BodyRow(props: BodyRowP const baseRowNode = ( ({ return [ Date: Tue, 14 Jan 2020 15:08:33 +0800 Subject: [PATCH 2/2] update test case --- tests/Table.spec.js | 17 +++++++++++++++++ tests/__snapshots__/ExpandRow.spec.js.snap | 14 ++++++++++++++ tests/__snapshots__/FixedColumn.spec.js.snap | 18 ++++++++++++++++++ tests/__snapshots__/Table.spec.js.snap | 13 +++++++++++++ 4 files changed, 62 insertions(+) diff --git a/tests/Table.spec.js b/tests/Table.spec.js index ed5b14ca3..721ba169f 100644 --- a/tests/Table.spec.js +++ b/tests/Table.spec.js @@ -729,4 +729,21 @@ describe('Table.Basic', () => { ); expect(wrapper.find('.test')).toHaveLength(1); }); + + it('component body should pass `data-row-key`', () => { + const wrapper = mount( + } }} + data={[{ test: 'bamboo', key: 'light' }]} + />, + ); + + expect( + wrapper + .find('tr') + .last() + .props()['data-row-key'], + ).toEqual('light'); + }); }); diff --git a/tests/__snapshots__/ExpandRow.spec.js.snap b/tests/__snapshots__/ExpandRow.spec.js.snap index 880dabf1b..72d4645fe 100644 --- a/tests/__snapshots__/ExpandRow.spec.js.snap +++ b/tests/__snapshots__/ExpandRow.spec.js.snap @@ -36,6 +36,7 @@ exports[`Table.Expand childrenColumnName 1`] = ` >