Skip to content
Merged
Changes from 1 commit
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
5 changes: 3 additions & 2 deletions src/VirtualTable/BodyLine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ const BodyLine = React.forwardRef<HTMLDivElement, BodyLineProps>((props, ref) =>
const { data, index, className, rowKey, style, extra, getHeight, ...restProps } = props;
const { record, indent, index: renderIndex } = data;

const { scrollX, flattenColumns, prefixCls, fixColumn, componentWidth } = useContext(
const { scrollX, flattenColumns, prefixCls, fixColumn, componentWidth, classNames } = useContext(
TableContext,
['prefixCls', 'flattenColumns', 'fixColumn', 'componentWidth', 'scrollX'],
['prefixCls', 'flattenColumns', 'fixColumn', 'componentWidth', 'scrollX', 'classNames'],
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

For consistency with the classNames fix, you should also extract styles from TableContext. This ensures that custom styles defined in the styles prop of the Table are also correctly applied to cells in virtual mode.

Suggested change
const { scrollX, flattenColumns, prefixCls, fixColumn, componentWidth, classNames } = useContext(
TableContext,
['prefixCls', 'flattenColumns', 'fixColumn', 'componentWidth', 'scrollX'],
['prefixCls', 'flattenColumns', 'fixColumn', 'componentWidth', 'scrollX', 'classNames'],
const { scrollX, flattenColumns, prefixCls, fixColumn, componentWidth, classNames, styles } = useContext(
TableContext,
['prefixCls', 'flattenColumns', 'fixColumn', 'componentWidth', 'scrollX', 'classNames', 'styles'],
);

);
const { getComponent } = useContext(StaticContext, ['getComponent']);

Expand Down Expand Up @@ -103,6 +103,7 @@ const BodyLine = React.forwardRef<HTMLDivElement, BodyLineProps>((props, ref) =>
return (
<VirtualCell
key={colIndex}
className={classNames?.body?.cell}
component={cellComponent}
rowInfo={rowInfo}
column={column}
Comment on lines +112 to 116
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.

high

While adding className, you should also pass style from styles.body.cell for consistency.

Additionally, it appears that several required props for VirtualCell (colIndex, indent, index, renderIndex, and record) are currently missing in this instantiation. These props are necessary for VirtualCell to correctly calculate cell properties (like fixed column offsets) and render data. Since they are available in the scope of BodyLine, they should be passed down.

Suggested change
className={classNames?.body?.cell}
component={cellComponent}
rowInfo={rowInfo}
column={column}
className={classNames?.body?.cell}
style={styles?.body?.cell}
component={cellComponent}
rowInfo={rowInfo}
column={column}
colIndex={colIndex}
indent={indent}
index={index}
renderIndex={renderIndex}
record={record}

Expand Down