Skip to content

Commit 93a01ee

Browse files
committed
fix: Should skip invalidate jsx
1 parent f26c38c commit 93a01ee

File tree

3 files changed

+23
-12
lines changed

3 files changed

+23
-12
lines changed

src/hooks/useColumns.tsx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,21 @@ import {
1313
import { INTERNAL_COL_DEFINE } from '../utils/legacyUtil';
1414

1515
function convertChildrenToColumns<RecordType>(children: React.ReactNode): ColumnsType<RecordType> {
16-
return toArray(children).map(({ key, props }: React.ReactElement) => {
17-
const { children: nodeChildren, ...restProps } = props;
18-
const column = {
19-
key,
20-
...restProps,
21-
};
22-
23-
if (nodeChildren) {
24-
column.children = convertChildrenToColumns(nodeChildren);
25-
}
16+
return toArray(children)
17+
.filter(node => React.isValidElement(node))
18+
.map(({ key, props }: React.ReactElement) => {
19+
const { children: nodeChildren, ...restProps } = props;
20+
const column = {
21+
key,
22+
...restProps,
23+
};
24+
25+
if (nodeChildren) {
26+
column.children = convertChildrenToColumns(nodeChildren);
27+
}
2628

27-
return column;
28-
});
29+
return column;
30+
});
2931
}
3032

3133
function flatColumns<RecordType>(columns: ColumnsType<RecordType>): ColumnType<RecordType>[] {

tests/FixedColumn.spec.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,4 +148,12 @@ describe('Table.FixedColumn', () => {
148148
);
149149
});
150150
});
151+
152+
it('ellipsis will wrap additional dom', () => {
153+
const myColumns = [{ ...columns[0], ellipsis: true }];
154+
const wrapper = mount(<Table columns={myColumns} data={data} />);
155+
156+
expect(wrapper.find('tr th').find('.rc-table-cell-content')).toHaveLength(1);
157+
expect(wrapper.find('tr td').find('.rc-table-cell-content')).toHaveLength(data.length);
158+
});
151159
});

tests/Table.spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,7 @@ describe('Table.Basic', () => {
638638
<ColumnGroup title="total">
639639
<Column title="Name" dataIndex="name" />
640640
</ColumnGroup>
641+
{'Invalidate Column'}
641642
</Table>,
642643
).render(),
643644
).toMatchSnapshot();

0 commit comments

Comments
 (0)