From ecfbaf03eb24ffd6197b3c3c759044c8ce3a424f Mon Sep 17 00:00:00 2001 From: Barry Wang Date: Thu, 17 Mar 2022 23:52:20 +0800 Subject: [PATCH 1/3] fix: table crashes if expandable set without scroll --- src/Table.tsx | 6 +- tests/ExpandRow.spec.js | 29 ++ tests/__snapshots__/ExpandRow.spec.js.snap | 304 +++++++++++++++++++++ 3 files changed, 336 insertions(+), 3 deletions(-) diff --git a/src/Table.tsx b/src/Table.tsx index 61412de41..4e2ab0884 100644 --- a/src/Table.tsx +++ b/src/Table.tsx @@ -432,7 +432,7 @@ function Table(props: TableProps(props: TableProps ellipsis)) { return 'fixed'; @@ -844,7 +844,7 @@ function Table(props: TableProps { expect(wrapper2.render()).toMatchSnapshot(); }); + it('does not crash if scroll is not set', () => { + const columns = [ + { title: 'Name', dataIndex: 'name', key: 'name' }, + { title: 'Age', dataIndex: 'age', key: 'age' }, + { title: 'Gender', dataIndex: 'gender', key: 'gender' }, + ]; + const data = [ + { key: 0, name: 'Lucy', age: 27, gender: 'F' }, + { key: 1, name: 'Jack', age: 28, gender: 'M' }, + ]; + const wrapper = mount( + createTable({ + columns, + data, + scroll: {}, + expandable: { expandedRowRender, fixed: true }, + }), + ); + const wrapper2 = mount( + createTable({ + columns, + data, + expandable: { expandedRowRender, fixed: true }, + }), + ); + expect(wrapper.render()).toMatchSnapshot(); + expect(wrapper2.render()).toMatchSnapshot(); + }); + it('expandable fix not when expandIconColumnIndex', () => { const columns = [ { title: 'Name', dataIndex: 'name', key: 'name' }, diff --git a/tests/__snapshots__/ExpandRow.spec.js.snap b/tests/__snapshots__/ExpandRow.spec.js.snap index ff95da721..e7dfdecf3 100644 --- a/tests/__snapshots__/ExpandRow.spec.js.snap +++ b/tests/__snapshots__/ExpandRow.spec.js.snap @@ -103,6 +103,310 @@ exports[`Table.Expand childrenColumnName 1`] = ` `; +exports[`Table.Expand does not crash if scroll is not set 1`] = ` +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + Name + + Age + + Gender +
+ + + Lucy + + 27 + + F +
+ + + Jack + + 28 + + M +
+
+
+
+`; + +exports[`Table.Expand does not crash if scroll is not set 2`] = ` +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + Name + + Age + + Gender +
+ + + Lucy + + 27 + + F +
+ + + Jack + + 28 + + M +
+
+
+
+`; + exports[`Table.Expand not use nest when children is invalidate 1`] = `
Date: Fri, 18 Mar 2022 10:22:01 +0800 Subject: [PATCH 2/3] fix: minor code fix on src/Table.tsx Co-authored-by: afc163 --- src/Table.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Table.tsx b/src/Table.tsx index 4e2ab0884..dda4ae778 100644 --- a/src/Table.tsx +++ b/src/Table.tsx @@ -553,7 +553,7 @@ function Table(props: TableProps ellipsis)) { return 'fixed'; From 5f178eeed84ac1764d3ac19a51a2faada7c9dce4 Mon Sep 17 00:00:00 2001 From: Barry Wang <36621849+Barrywww@users.noreply.github.com> Date: Fri, 18 Mar 2022 10:44:56 +0800 Subject: [PATCH 3/3] fix: minor code fix on src/Table.tsx Co-authored-by: afc163 --- src/Table.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Table.tsx b/src/Table.tsx index dda4ae778..090296baf 100644 --- a/src/Table.tsx +++ b/src/Table.tsx @@ -432,7 +432,7 @@ function Table(props: TableProps