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
2 changes: 1 addition & 1 deletion src/ColGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function ColGroup<RecordType>({ colWidths, columns, columCount }: ColGroupProps<
for (let i = len - 1; i >= 0; i -= 1) {
const width = colWidths[i];
const column = columns && columns[i];
let additionalProps;
let additionalProps: Record<string, unknown>;
let minWidth: number;
if (column) {
additionalProps = column[INTERNAL_COL_DEFINE];
Expand Down
17 changes: 15 additions & 2 deletions src/FixedHolder/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,13 @@ const FixedHolder = React.forwardRef<HTMLDivElement, FixedHeaderProps<any>>((pro

const colGroupNode = useMemo(() => {
// use original ColGroup if no data or no calculated column width, otherwise use calculated column width
if (noData || !mergedColumnWidth) {
// 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;
}
return (
Expand All @@ -149,7 +155,14 @@ const FixedHolder = React.forwardRef<HTMLDivElement, FixedHeaderProps<any>>((pro
columns={flattenColumnsWithScrollbar}
/>
);
}, [noData, mergedColumnWidth, colGroup, combinationScrollBarSize, columCount, flattenColumnsWithScrollbar]);
}, [
noData,
mergedColumnWidth,
colGroup,
combinationScrollBarSize,
columCount,
flattenColumnsWithScrollbar,
]);

return (
<div
Expand Down
15 changes: 1 addition & 14 deletions tests/__snapshots__/Table.spec.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -216,20 +216,7 @@ LoadedCheerio {
<table
style="table-layout: fixed; width: 100px; min-width: 100%;"
>
<colgroup>
<col
style="width: 0px;"
/>
<col
style="width: 0px;"
/>
<col
style="width: 0px;"
/>
<col
style="width: 15px;"
/>
</colgroup>
<colgroup />
<thead
class="rc-table-thead"
name="my-header-wrapper"
Expand Down