Skip to content
Merged
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
20 changes: 14 additions & 6 deletions src/VirtualTable/BodyLine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,16 @@ 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(
TableContext,
['prefixCls', 'flattenColumns', 'fixColumn', 'componentWidth', 'scrollX'],
);
const { scrollX, flattenColumns, prefixCls, fixColumn, componentWidth, classNames, styles } =
useContext(TableContext, [
'prefixCls',
'flattenColumns',
'fixColumn',
'componentWidth',
'scrollX',
'classNames',
'styles',
]);
const { getComponent } = useContext(StaticContext, ['getComponent']);

const rowInfo = useRowInfo(record, rowKey, index, indent);
Expand Down Expand Up @@ -93,16 +99,18 @@ const BodyLine = React.forwardRef<HTMLDivElement, BodyLineProps>((props, ref) =>
{...restProps}
data-row-key={rowKey}
ref={rowSupportExpand ? null : ref}
className={clsx(className, `${prefixCls}-row`, rowProps?.className, {
className={clsx(className, `${prefixCls}-row`, rowProps?.className, classNames?.body?.row, {
[expandedClsName]: indent >= 1,
[`${prefixCls}-row-extra`]: extra,
})}
style={{ ...rowStyle, ...rowProps?.style }}
style={{ ...rowStyle, ...rowProps?.style, ...styles?.body?.row }}
>
{flattenColumns.map((column, colIndex) => {
return (
<VirtualCell
key={colIndex}
className={classNames?.body?.cell}
style={styles?.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
Loading