Skip to content

Commit bae77c1

Browse files
committed
fix(Table): error when colspan with ListTable, close #2004
1 parent 810de2d commit bae77c1

File tree

1 file changed

+12
-28
lines changed

1 file changed

+12
-28
lines changed

src/table/list/row.jsx

+12-28
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,11 @@ export default class GroupListRow extends Row {
6464
}
6565

6666
isChildrenSelection() {
67-
return (
68-
this.context.listHeader &&
69-
this.context.listHeader.hasChildrenSelection
70-
);
67+
return this.context.listHeader && this.context.listHeader.hasChildrenSelection;
7168
}
7269

7370
isFirstLevelDataWhenNoChildren() {
74-
return (
75-
this.context.listHeader &&
76-
this.context.listHeader.useFirstLevelDataWhenNoChildren
77-
);
71+
return this.context.listHeader && this.context.listHeader.useFirstLevelDataWhenNoChildren;
7872
}
7973

8074
isSelection() {
@@ -107,10 +101,12 @@ export default class GroupListRow extends Row {
107101
}
108102
if (this.context.rowSelection) {
109103
cells.shift();
110-
cells[0] = React.cloneElement(cells[0], {
111-
colSpan: 2,
112-
...cells[0].props,
113-
});
104+
cells[0] =
105+
cells[0] &&
106+
React.cloneElement(cells[0], {
107+
colSpan: 2,
108+
...cells[0].props,
109+
});
114110
}
115111
return <tr key={index}>{cells}</tr>;
116112
});
@@ -133,31 +129,19 @@ export default class GroupListRow extends Row {
133129
}
134130
if (listNode) {
135131
let cells = this.renderCells(record);
136-
if (
137-
type === 'header' &&
138-
this.context.rowSelection &&
139-
this.isSelection()
140-
) {
132+
if (type === 'header' && this.context.rowSelection && this.isSelection()) {
141133
cells = cells.slice(0, 1);
142134
cells.push(
143135
<td colSpan={columns.length - 1} key="listNode">
144-
<div className={`${prefix}table-cell-wrapper`}>
145-
{listNode}
146-
</div>
136+
<div className={`${prefix}table-cell-wrapper`}>{listNode}</div>
147137
</td>
148138
);
149-
listNode = (
150-
<tr className={`${prefix}table-group-${type}`}>
151-
{cells}
152-
</tr>
153-
);
139+
listNode = <tr className={`${prefix}table-group-${type}`}>{cells}</tr>;
154140
} else {
155141
listNode = (
156142
<tr className={`${prefix}table-group-${type}`}>
157143
<td colSpan={columns.length}>
158-
<div className={`${prefix}table-cell-wrapper`}>
159-
{listNode}
160-
</div>
144+
<div className={`${prefix}table-cell-wrapper`}>{listNode}</div>
161145
</td>
162146
</tr>
163147
);

0 commit comments

Comments
 (0)