Skip to content

Commit c3a21ff

Browse files
committed
feat: review
1 parent 92106b5 commit c3a21ff

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

src/Body/BodyRow.tsx

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -72,36 +72,36 @@ export function getCellProps<RecordType>(
7272
);
7373
}
7474

75-
const addChildrenRowSpan = (rowSpan: number, idx: number) => {
76-
const nextIndex = idx + 1;
77-
const rowKey = rowKeys[nextIndex];
78-
let _rowSpan = rowSpan;
79-
if (rowKey !== undefined) {
80-
// 下面如果是 0 的,增加 +1 逻辑
81-
const thisCellProps = column.onCell(record, nextIndex);
82-
if (thisCellProps.rowSpan === 0) {
83-
const thisExpanded = expandedKeys.has(rowKey);
84-
if (thisExpanded) {
85-
_rowSpan = _rowSpan + 1;
86-
}
87-
// 继续往下找
88-
return addChildrenRowSpan(_rowSpan, nextIndex);
89-
}
90-
}
91-
// 找不到后返回
92-
return _rowSpan;
93-
};
94-
9575
let additionalCellProps: React.TdHTMLAttributes<HTMLElement>;
9676
if (column.onCell) {
9777
additionalCellProps = column.onCell(record, index);
9878
// 开启 expanded 的增加下面逻辑
9979
if (expandable) {
80+
// 当前为合并单元格开始
10081
if (additionalCellProps.rowSpan > 0) {
10182
// 本身展开 +1
10283
if (expanded) {
10384
additionalCellProps.rowSpan = additionalCellProps.rowSpan + 1;
10485
}
86+
// 下面如果是 0 的,增加 +1 逻辑
87+
const addChildrenRowSpan = (rowSpan: number, idx: number) => {
88+
const nextIndex = idx + 1;
89+
const rowKey = rowKeys[nextIndex];
90+
let _rowSpan = rowSpan;
91+
if (rowKey !== undefined) {
92+
const thisCellProps = column.onCell(record, nextIndex);
93+
if (thisCellProps.rowSpan === 0) {
94+
const thisExpanded = expandedKeys.has(rowKey);
95+
if (thisExpanded) {
96+
_rowSpan = _rowSpan + 1;
97+
}
98+
// 继续往下找
99+
return addChildrenRowSpan(_rowSpan, nextIndex);
100+
}
101+
}
102+
// 找不到后返回
103+
return _rowSpan;
104+
};
105105
additionalCellProps.rowSpan = addChildrenRowSpan(additionalCellProps.rowSpan, index);
106106
}
107107
}

0 commit comments

Comments
 (0)