Skip to content
Open
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: 6 additions & 5 deletions src/FixedHolder/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ const FixedHolder = React.forwardRef<HTMLDivElement, FixedHeaderProps<any>>((pro
const {
className,
style,
noData,
columns,
Comment on lines 51 to 54
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

By removing noData from the destructuring assignment, it now implicitly falls into restProps. Since restProps is passed down to the children render prop (which eventually renders the header elements), noData will be forwarded down and may end up being spread onto DOM elements, triggering React console warnings (e.g., React does not recognize the noData prop on a DOM element).

To prevent this prop leakage, keep noData in the destructuring assignment so it is excluded from restProps, even if it is not directly used within FixedHolder.

Suggested change
const {
className,
style,
noData,
columns,
const {
className,
style,
noData,
columns,

flattenColumns,
colWidths,
Expand Down Expand Up @@ -160,12 +159,14 @@ const FixedHolder = React.forwardRef<HTMLDivElement, FixedHeaderProps<any>>((pro
const mergedColumnWidth = useColumnWidth(colWidths, columCount);

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
// ColGroup should be rendered as long as column widths are available,
// even if there is no data. This maintains layout consistency between
// Header, Body, and Summary sections.
// Ref: https://github.com/ant-design/ant-design/issues/57916
const noWidth =
!mergedColumnWidth || !mergedColumnWidth.length || mergedColumnWidth.every(w => !w);
return noData || noWidth;
}, [noData, mergedColumnWidth]);
return noWidth;
}, [mergedColumnWidth]);
Comment thread
wanpan11 marked this conversation as resolved.

return (
<div
Expand Down
45 changes: 33 additions & 12 deletions tests/__snapshots__/FixedColumn.spec.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2698,22 +2698,43 @@ exports[`Table.FixedColumn > renders correctly > scrollXY - without data 1`] = `
>
<colgroup>
<col
style="width: 100px;"
style="width: 1000px;"
/>
<col
style="width: 100px;"
style="width: 1000px;"
/>
<col />
<col />
<col />
<col />
<col />
<col />
<col />
<col />
<col />
<col
style="width: 100px;"
style="width: 1000px;"
/>
<col
style="width: 1000px;"
/>
<col
style="width: 1000px;"
/>
<col
style="width: 1000px;"
/>
<col
style="width: 1000px;"
/>
<col
style="width: 1000px;"
/>
<col
style="width: 1000px;"
/>
<col
style="width: 1000px;"
/>
<col
style="width: 1000px;"
/>
<col
style="width: 1000px;"
/>
<col
style="width: 15px;"
/>
</colgroup>
<thead
Expand Down