Skip to content

fix: pass classNames.body.cell to VirtualCell in virtual mode#1487

Merged
afc163 merged 3 commits intoreact-component:masterfrom
gavanx:fix/virtual-classnames-body-cell
May 8, 2026
Merged

fix: pass classNames.body.cell to VirtualCell in virtual mode#1487
afc163 merged 3 commits intoreact-component:masterfrom
gavanx:fix/virtual-classnames-body-cell

Conversation

@gavanx
Copy link
Copy Markdown
Contributor

@gavanx gavanx commented May 7, 2026

In non-virtual mode, Body/index.tsx extracts classNames from TableContext and passes classNames.body to BodyRow, which then applies classNames.cell to each Cell. However, VirtualTable/BodyLine.tsx does not read classNames from TableContext, so VirtualCell never receives the body cell className.

This causes custom cell classNames (e.g. from antd's Table wrapper like itp-design) to be missing on cells rendered in virtual scroll mode.

non-virtual
img_v3_0211f_93295b97-83db-4a9e-8b05-44769a8dc43g

virtual
img_v3_0211f_4283994f-9fb1-44c8-8df4-84f3180bcbfg

Summary by CodeRabbit

发布说明

  • 改进
    • 虚拟表格的行与单元格样式现在可通过表级配置统一控制,行样式会与每行样式合并应用,单元格可接收表级样式与类名,便于全表范围的视觉定制与一致性调整。

In non-virtual mode, Body/index.tsx extracts classNames from TableContext
and passes classNames.body to BodyRow, which then applies classNames.cell
to each Cell. However, VirtualTable/BodyLine.tsx does not read classNames
from TableContext, so VirtualCell never receives the body cell className.

This causes custom cell classNames (e.g. from antd's Table wrapper like
itp-design) to be missing on cells rendered in virtual scroll mode.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 7, 2026

@gavanx is attempting to deploy a commit to the React Component Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 7, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e10cba91-3c36-42cc-bcb2-272699b83878

📥 Commits

Reviewing files that changed from the base of the PR and between de7fb33 and 41d5882.

📒 Files selected for processing (1)
  • src/VirtualTable/BodyLine.tsx

Walkthrough

BodyLine 从 TableContext 解构出 classNamesstyles,在渲染行时合并并应用 styles.body.rowclassNames?.body?.row,并在创建每个 VirtualCell 时传入 className={classNames?.body?.cell}style={styles?.body?.cell}

变更详情

虚拟表格体单元格样式配置

层级 / 文件 摘要
上下文数据结构
src/VirtualTable/BodyLine.tsx
BodyLineTableContext 解构扩展为包含 classNamesstyles 字段。
行样式合并
src/VirtualTable/BodyLine.tsx
渲染行容器时合并并应用 styles.body.row 并添加 classNames?.body?.row 到行的样式与类名。
单元格样式应用
src/VirtualTable/BodyLine.tsx
VirtualCell 渲染时传入 className={classNames?.body?.cell}style={styles?.body?.cell},启用表级体单元格样式透传。

预估代码审查工作量

🎯 2 (Simple) | ⏱️ ~8 minutes

可能相关的 PR

推荐审查人

  • afc163
  • zombieJ

走查说明

BodyLine 组件从 TableContext 中解构出 classNamesstyles,渲染行时将 styles.body.rowclassNames?.body?.row 合并到行的 style/className,渲染每个 VirtualCell 时传入 classNames?.body?.cellstyles?.body?.cell 以实现表级体单元格样式控制。

诗歌

兔子踮脚看格子行,
上下文携样式来轻盈,
行与格披新装闪亮,
渲染稳当又不惊。🐰

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title states 'pass classNames.body.cell to VirtualCell' but the actual changes also include passing classNames.body.row and styles properties to RowComponent, which is a significant part of the fix that isn't reflected in the title. Update the title to comprehensively reflect both cell and row-level styling fixes, such as: 'fix: pass body cell and row classNames/styles to VirtualTable BodyLine components'
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates BodyLine.tsx to extract classNames from TableContext and apply them to the VirtualCell component. The feedback suggests also extracting and applying styles from the context for consistency. Furthermore, the reviewer identified that several required props for VirtualCell, such as colIndex, indent, and record, are currently missing and should be passed down to ensure correct rendering and property calculations.

Comment on lines +106 to 109
className={classNames?.body?.cell}
component={cellComponent}
rowInfo={rowInfo}
column={column}
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}

Comment thread src/VirtualTable/BodyLine.tsx Outdated
Comment on lines +28 to +30
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'],
);

gavanx and others added 2 commits May 8, 2026 09:47
VirtualTable's BodyLine only forwarded classNames.body.cell but missed
styles.body.cell, causing style customizations via the styles prop to be
ignored in virtual mode while working in non-virtual mode.
…virtual mode

BodyLine's RowComponent was missing classNames.body.row and
styles.body.row, causing row-level customizations to be ignored
in virtual mode while working in non-virtual BodyRow.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.12%. Comparing base (80fcd5e) to head (41d5882).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1487   +/-   ##
=======================================
  Coverage   96.11%   96.12%           
=======================================
  Files          57       57           
  Lines        3448     3456    +8     
  Branches      635      639    +4     
=======================================
+ Hits         3314     3322    +8     
  Misses        129      129           
  Partials        5        5           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@afc163 afc163 merged commit d5b5bb1 into react-component:master May 8, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants