Skip to content

Commit ffdedc2

Browse files
authored
fix: Not render children when invalidate (#508)
1 parent 0234dd8 commit ffdedc2

File tree

3 files changed

+96
-1
lines changed

3 files changed

+96
-1
lines changed

src/Table.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ function Table<RecordType extends DefaultRecordType>(props: TableProps<RecordTyp
286286
internalHooks === INTERNAL_HOOKS &&
287287
(props.expandable as any).__PARENT_RENDER_ICON__) ||
288288
mergedData.some(
289-
record => record && typeof record === 'object' && mergedChildrenColumnName in record,
289+
record => record && typeof record === 'object' && record[mergedChildrenColumnName],
290290
)
291291
) {
292292
return 'nest';

tests/ExpandRow.spec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@ describe('Table.Expand', () => {
7171
expect(wrapper.render()).toMatchSnapshot();
7272
});
7373

74+
it('not use nest when children is invalidate', () => {
75+
const data = [
76+
{ key: 2, name: 'Jack', age: 28, children: null },
77+
{ key: 4, name: 'Jack', age: 28, children: undefined },
78+
{ key: 5, name: 'Jack', age: 28, children: false },
79+
];
80+
const wrapper = mount(createTable({ data }));
81+
expect(wrapper.render()).toMatchSnapshot();
82+
});
83+
7484
it('childrenColumnName', () => {
7585
const data = [
7686
{

tests/__snapshots__/ExpandRow.spec.js.snap

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,91 @@ exports[`Table.Expand childrenColumnName 1`] = `
103103
</div>
104104
`;
105105

106+
exports[`Table.Expand not use nest when children is invalidate 1`] = `
107+
<div
108+
class="rc-table"
109+
>
110+
<div
111+
class="rc-table-container"
112+
>
113+
<div
114+
class="rc-table-content"
115+
>
116+
<table
117+
style="table-layout: auto;"
118+
>
119+
<colgroup />
120+
<thead
121+
class="rc-table-thead"
122+
>
123+
<tr>
124+
<th
125+
class="rc-table-cell"
126+
>
127+
Name
128+
</th>
129+
<th
130+
class="rc-table-cell"
131+
>
132+
Age
133+
</th>
134+
</tr>
135+
</thead>
136+
<tbody
137+
class="rc-table-tbody"
138+
>
139+
<tr
140+
class="rc-table-row rc-table-row-level-0"
141+
data-row-key="2"
142+
>
143+
<td
144+
class="rc-table-cell"
145+
>
146+
Jack
147+
</td>
148+
<td
149+
class="rc-table-cell"
150+
>
151+
28
152+
</td>
153+
</tr>
154+
<tr
155+
class="rc-table-row rc-table-row-level-0"
156+
data-row-key="4"
157+
>
158+
<td
159+
class="rc-table-cell"
160+
>
161+
Jack
162+
</td>
163+
<td
164+
class="rc-table-cell"
165+
>
166+
28
167+
</td>
168+
</tr>
169+
<tr
170+
class="rc-table-row rc-table-row-level-0"
171+
data-row-key="5"
172+
>
173+
<td
174+
class="rc-table-cell"
175+
>
176+
Jack
177+
</td>
178+
<td
179+
class="rc-table-cell"
180+
>
181+
28
182+
</td>
183+
</tr>
184+
</tbody>
185+
</table>
186+
</div>
187+
</div>
188+
</div>
189+
`;
190+
106191
exports[`Table.Expand renders fixed column correctly work 1`] = `
107192
<div
108193
class="rc-table rc-table-fixed-column rc-table-scroll-horizontal rc-table-has-fix-left rc-table-has-fix-right"

0 commit comments

Comments
 (0)