Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions docs/examples/measureRowRender.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,14 @@ const data = [
];

// 自定义 MeasureRow 渲染,隐藏弹层内容
const measureRowRender: TableProps['measureRowRender'] = measureRow => (
<div style={{ display: 'none' }}>{measureRow}</div>
);
const measureRowRender: TableProps['measureRowRender'] = measureRow => {
if (React.isValidElement(measureRow)) {
return React.cloneElement<any>(measureRow, {
style: { ...(measureRow.props as any).style, display: 'none' },
});
}
return measureRow;
};

// 示例:使用 measureRowRender 来隐藏 MeasureRow 中的弹层
const MeasureRowRenderExample: React.FC = () => {
Expand Down
36 changes: 12 additions & 24 deletions src/FixedHolder/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,31 +157,13 @@ const FixedHolder = React.forwardRef<HTMLDivElement, FixedHeaderProps<any>>((pro

const mergedColumnWidth = useColumnWidth(colWidths, columCount);

const colGroupNode = useMemo(() => {
const isColGroupEmpty = useMemo<boolean>(() => {
// use original ColGroup if no data or no calculated column width, otherwise use calculated column width
// Return original colGroup if no data, or mergedColumnWidth is empty, or all widths are falsy
if (
noData ||
!mergedColumnWidth ||
mergedColumnWidth.length === 0 ||
mergedColumnWidth.every(width => !width)
) {
return ColGroup;
Copy link
Member Author

@li-jia-nan li-jia-nan Sep 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ColGroup 是一个函数,直接渲染到 UI 会报错,这里应该返回 null

}
return (
<ColGroup
colWidths={[...mergedColumnWidth, combinationScrollBarSize]}
columCount={columCount + 1}
columns={flattenColumnsWithScrollbar}
/>
);
}, [
noData,
mergedColumnWidth,
combinationScrollBarSize,
columCount,
flattenColumnsWithScrollbar,
]);
const noWidth =
!mergedColumnWidth || !mergedColumnWidth.length || mergedColumnWidth.every(w => !w);
return noData || noWidth;
}, [noData, mergedColumnWidth]);

return (
<div
Expand All @@ -203,7 +185,13 @@ const FixedHolder = React.forwardRef<HTMLDivElement, FixedHeaderProps<any>>((pro
width: scrollX,
}}
>
{colGroupNode}
{isColGroupEmpty ? null : (
<ColGroup
colWidths={[...mergedColumnWidth, combinationScrollBarSize]}
columCount={columCount + 1}
columns={flattenColumnsWithScrollbar}
/>
)}
{children({
...restProps,
stickyOffsets: headerStickyOffsets,
Expand Down