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
2 changes: 1 addition & 1 deletion src/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ function Table<RecordType extends DefaultRecordType>(props: TableProps<RecordTyp
internalHooks === INTERNAL_HOOKS &&
(props.expandable as any).__PARENT_RENDER_ICON__) ||
mergedData.some(
record => record && typeof record === 'object' && mergedChildrenColumnName in record,
record => record && typeof record === 'object' && record[mergedChildrenColumnName],
)
) {
return 'nest';
Expand Down
10 changes: 10 additions & 0 deletions tests/ExpandRow.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
{
Expand Down
85 changes: 85 additions & 0 deletions tests/__snapshots__/ExpandRow.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,91 @@ exports[`Table.Expand childrenColumnName 1`] = `
</div>
`;

exports[`Table.Expand not use nest when children is invalidate 1`] = `
<div
class="rc-table"
>
<div
class="rc-table-container"
>
<div
class="rc-table-content"
>
<table
style="table-layout: auto;"
>
<colgroup />
<thead
class="rc-table-thead"
>
<tr>
<th
class="rc-table-cell"
>
Name
</th>
<th
class="rc-table-cell"
>
Age
</th>
</tr>
</thead>
<tbody
class="rc-table-tbody"
>
<tr
class="rc-table-row rc-table-row-level-0"
data-row-key="2"
>
<td
class="rc-table-cell"
>
Jack
</td>
<td
class="rc-table-cell"
>
28
</td>
</tr>
<tr
class="rc-table-row rc-table-row-level-0"
data-row-key="4"
>
<td
class="rc-table-cell"
>
Jack
</td>
<td
class="rc-table-cell"
>
28
</td>
</tr>
<tr
class="rc-table-row rc-table-row-level-0"
data-row-key="5"
>
<td
class="rc-table-cell"
>
Jack
</td>
<td
class="rc-table-cell"
>
28
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
`;

exports[`Table.Expand renders fixed column correctly work 1`] = `
<div
class="rc-table rc-table-fixed-column rc-table-scroll-horizontal rc-table-has-fix-left rc-table-has-fix-right"
Expand Down