diff --git a/src/Table.tsx b/src/Table.tsx index af680c27b..d9c005dac 100644 --- a/src/Table.tsx +++ b/src/Table.tsx @@ -286,7 +286,7 @@ function Table(props: TableProps record && typeof record === 'object' && mergedChildrenColumnName in record, + record => record && typeof record === 'object' && record[mergedChildrenColumnName], ) ) { return 'nest'; diff --git a/tests/ExpandRow.spec.js b/tests/ExpandRow.spec.js index 6452bf933..66e50a2c4 100644 --- a/tests/ExpandRow.spec.js +++ b/tests/ExpandRow.spec.js @@ -71,6 +71,16 @@ describe('Table.Expand', () => { expect(wrapper.render()).toMatchSnapshot(); }); + it('not use nest when children is invalidate', () => { + const data = [ + { key: 2, name: 'Jack', age: 28, children: null }, + { key: 4, name: 'Jack', age: 28, children: undefined }, + { key: 5, name: 'Jack', age: 28, children: false }, + ]; + const wrapper = mount(createTable({ data })); + expect(wrapper.render()).toMatchSnapshot(); + }); + it('childrenColumnName', () => { const data = [ { diff --git a/tests/__snapshots__/ExpandRow.spec.js.snap b/tests/__snapshots__/ExpandRow.spec.js.snap index 9b83f29a4..ffda7003b 100644 --- a/tests/__snapshots__/ExpandRow.spec.js.snap +++ b/tests/__snapshots__/ExpandRow.spec.js.snap @@ -103,6 +103,91 @@ exports[`Table.Expand childrenColumnName 1`] = ` `; +exports[`Table.Expand not use nest when children is invalidate 1`] = ` +
+
+
+ + + + + + + + + + + + + + + + + + + + + + +
+ Name + + Age +
+ Jack + + 28 +
+ Jack + + 28 +
+ Jack + + 28 +
+
+
+
+`; + exports[`Table.Expand renders fixed column correctly work 1`] = `