Skip to content

Commit b763fd2

Browse files
committed
chore: update span logic
1 parent 82d959c commit b763fd2

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

docs/examples/virtual.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,14 @@ const columns: ColumnsType = [
160160
},
161161
];
162162

163-
function cleanOnCell(cols: any = []) {
163+
export function cleanOnCell(cols: any = []) {
164164
cols.forEach(col => {
165165
delete (col as any).onCell;
166166

167167
cleanOnCell((col as any).children);
168168
});
169169
}
170-
cleanOnCell(columns);
170+
// cleanOnCell(columns);
171171

172172
const data: RecordType[] = new Array(4 * 10000).fill(null).map((_, index) => ({
173173
a: `a${index}`,
@@ -201,11 +201,11 @@ const Demo = () => {
201201
scroll={{ x: 1200, y: scrollY ? 200 : null }}
202202
data={data}
203203
rowKey="indexKey"
204-
expandable={{
205-
expandedRowRender: () => 2333,
206-
columnWidth: 60,
207-
expandedRowClassName: () => 'good-one',
208-
}}
204+
// expandable={{
205+
// expandedRowRender: () => 2333,
206+
// columnWidth: 60,
207+
// expandedRowClassName: () => 'good-one',
208+
// }}
209209
// onRow={() => ({ className: 'rowed' })}
210210
rowClassName="nice-try"
211211
/>

src/VirtualTable/VirtualCell.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import * as React from 'react';
2-
import { getCellProps, type useRowInfo } from '../Body/BodyRow';
2+
import { getCellProps } from '../Body/BodyRow';
33
import Cell from '../Cell';
44
import type { ColumnType } from '../interface';
55
import classNames from 'classnames';
66
import { useContext } from '@rc-component/context';
77
import { GridContext } from './context';
8+
import type useRowInfo from '../hooks/useRowInfo';
89

910
export interface VirtualCellProps<RecordType extends { index: number }> {
1011
rowInfo: ReturnType<typeof useRowInfo>;
@@ -88,6 +89,14 @@ function VirtualCell<RecordType extends { index: number } = any>(
8889
const mergedRender = needHide ? () => null : render;
8990

9091
// ========================== Render ==========================
92+
const cellSpan: React.TdHTMLAttributes<HTMLElement> = {};
93+
94+
// Virtual should reset `colSpan` & `rowSpan`
95+
if (rowSpan === 0 || colSpan === 0) {
96+
cellSpan.rowSpan = 1;
97+
cellSpan.colSpan = 1;
98+
}
99+
91100
return (
92101
<Cell
93102
className={classNames(columnClassName, className)}
@@ -108,10 +117,7 @@ function VirtualCell<RecordType extends { index: number } = any>(
108117
additionalProps={{
109118
...additionalCellProps,
110119
style: mergedStyle,
111-
112-
// Virtual should reset `colSpan` & `rowSpan`
113-
rowSpan: 1,
114-
colSpan: 1,
120+
...cellSpan,
115121
}}
116122
/>
117123
);

0 commit comments

Comments
 (0)