Skip to content

feat: support force rendering expanded rows - #1503

Open
nikzanda wants to merge 2 commits into
react-component:masterfrom
nikzanda:feat/expandable-force-render
Open

feat: support force rendering expanded rows#1503
nikzanda wants to merge 2 commits into
react-component:masterfrom
nikzanda:feat/expandable-force-render

Conversation

@nikzanda

@nikzanda nikzanda commented Jul 28, 2026

Copy link
Copy Markdown

Summary

  • Add expandable.forceRender
  • Render collapsed expanded-row content ahead of the first expansion
  • Support both regular and virtual tables
  • Keep force-rendered rows hidden until expanded

Related issue

Related to ant-design/ant-design#54798

Summary by CodeRabbit

  • 新功能
    • 新增 expandable.forceRender 配置项(默认值 false)。
    • 启用后,可展开行会在展开前先行渲染展开内容,并保持隐藏;点击展开后显示,再次收起时恢复隐藏状态。
    • 虚拟表格模式下同样支持该展开行预渲染与切换效果。
  • 文档
    • 更新中英文 API 文档的 expandable 配置说明,补充 forceRender 的类型、默认值及用途。

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@vercel

vercel Bot commented Jul 28, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the afc163's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

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 Plus

Run ID: a344ce48-03fe-4afe-8c86-be7eea031401

📥 Commits

Reviewing files that changed from the base of the PR and between 2a55be7 and 536bdc8.

📒 Files selected for processing (2)
  • tests/ExpandRow.spec.jsx
  • tests/Virtual.spec.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/ExpandRow.spec.jsx
  • tests/Virtual.spec.tsx

Walkthrough

新增 expandable.forceRender 配置,并将其传递至行信息。普通表格和虚拟表格会提前渲染展开行,未展开时隐藏内容;同时补充类型定义、文档及测试。

Changes

展开行强制渲染

Layer / File(s) Summary
配置契约与上下文传递
src/interface.ts, src/context/TableContext.tsx, src/hooks/useRowInfo.tsx, src/Table.tsx
新增 forceRender 配置类型,并通过表格上下文和 useRowInfo 传递至行组件。
展开行渲染行为
src/Body/BodyRow.tsx, src/VirtualTable/BodyLine.tsx
普通及虚拟表格在启用 forceRender 时提前渲染展开行;虚拟表格未展开时使用 display: none 隐藏内容。
行为验证与 API 文档
tests/ExpandRow.spec.jsx, tests/Virtual.spec.tsx, README.md, README.zh-CN.md
测试预渲染、隐藏和展开后的可见性,并在中英文文档中记录配置项。

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Table
  participant TableContext
  participant RowInfo
  participant BodyRow
  participant BodyLine
  participant ExpandedRow
  Table->>TableContext: 写入 expandable.forceRender
  TableContext->>RowInfo: 选择 forceRender
  RowInfo->>BodyRow: 提供展开配置
  RowInfo->>BodyLine: 提供展开配置
  BodyRow->>ExpandedRow: forceRender 时预先渲染
  BodyLine->>ExpandedRow: forceRender 时创建并隐藏
  BodyLine->>ExpandedRow: 展开后移除隐藏样式
Loading

Suggested reviewers: zombiej

Poem

Poem

小兔挥爪改展开,
行儿未开先露脸。
藏在屏幕后安睡,
点击之后光灿灿。
类型文档齐欢唱,
测试萝卜甜又香。

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题与变更一致,清楚概括了新增展开行强制渲染能力。
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.


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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tests/ExpandRow.spec.jsx (1)

62-65: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

补充重新折叠后的隐藏断言。

当前仅验证首次展开;若 forceRender 路径在折叠后未恢复 display: none,测试不会捕获回归。

  • tests/ExpandRow.spec.jsx#L62-L65:再次点击第一行展开图标,并断言第一条展开行恢复隐藏。
  • tests/Virtual.spec.tsx#L201-L205:再次点击展开图标,并断言虚拟展开行恢复隐藏。

依据 PR 目标,强制渲染的内容应在未展开时保持隐藏。

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/ExpandRow.spec.jsx` around lines 62 - 65, Extend the expansion
assertions in tests/ExpandRow.spec.jsx lines 62-65 by clicking the first row’s
expand icon again and asserting its expanded row is hidden; apply the same
additional collapse interaction and hidden-state assertion in
tests/Virtual.spec.tsx lines 201-205. Ensure both force-render paths verify
content remains hidden after collapsing.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tests/ExpandRow.spec.jsx`:
- Around line 62-65: Extend the expansion assertions in tests/ExpandRow.spec.jsx
lines 62-65 by clicking the first row’s expand icon again and asserting its
expanded row is hidden; apply the same additional collapse interaction and
hidden-state assertion in tests/Virtual.spec.tsx lines 201-205. Ensure both
force-render paths verify content remains hidden after collapsing.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b021e53e-c774-4b76-af09-561b172fd7ff

📥 Commits

Reviewing files that changed from the base of the PR and between adf0701 and 2a55be7.

📒 Files selected for processing (10)
  • README.md
  • README.zh-CN.md
  • src/Body/BodyRow.tsx
  • src/Table.tsx
  • src/VirtualTable/BodyLine.tsx
  • src/context/TableContext.tsx
  • src/hooks/useRowInfo.tsx
  • src/interface.ts
  • tests/ExpandRow.spec.jsx
  • tests/Virtual.spec.tsx

@nikzanda

Copy link
Copy Markdown
Author

Related work

This PR overlaps with #1386. Thanks to @rubbishmaker for the earlier implementation.

Compared with #1386, this PR:

I'm happy to rework or close this PR if maintainers prefer continuing from #1386.

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.

1 participant