Skip to content

feat: support expand all control in expandable column header - #1505

Open
nikzanda wants to merge 3 commits into
react-component:masterfrom
nikzanda:feat/expand-all-header
Open

feat: support expand all control in expandable column header#1505
nikzanda wants to merge 3 commits into
react-component:masterfrom
nikzanda:feat/expand-all-header

Conversation

@nikzanda

@nikzanda nikzanda commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Add an opt-in expand/collapse-all control to the expandable column header.

This is intended to support the use case described in ant-design/ant-design#8791.

The implementation is ready for maintainer review. The corresponding Ant Design integration will follow once the API is accepted and released.

API

  • Add expandable.showExpandAll to enable the header control.
  • Add expandable.expandAllIcon to customize its rendering.
  • Add expandable.onExpandAll to observe expand/collapse-all actions.
  • Allow expandable.columnTitle to be a render function receiving the generated expand-all control.

Behavior

  • The feature is disabled by default.
  • Only rows allowed by rowExpandable are affected.
  • Controlled and uncontrolled expandedRowKeys are supported.
  • Existing unrelated expanded keys are preserved.
  • Both the default and custom expand-all icons are supported.
  • The control is currently limited to expandedRowRender tables.

Testing

Added regression coverage for:

  • opt-in rendering
  • expanding and collapsing all rows
  • rowExpandable filtering
  • controlled expandedRowKeys
  • preservation of unrelated expanded keys
  • custom expandAllIcon
  • composition through columnTitle

Validation:

  • yarn test tests/ExpandRow.spec.jsx
  • yarn tsc
  • yarn lint

Summary by CodeRabbit

  • 新功能
    • 新增“全部展开/收起”控件,支持一键操作所有可展开行。
    • 支持自定义展开全部图标和展开列标题。
    • 新增展开全部状态回调,并支持按条件筛选可展开行。
  • 文档
    • 更新中英文文档,补充相关配置项和回调说明。
  • 测试
    • 增加全部展开、收起、自定义图标及条件筛选等场景测试。

@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 29, 2026

Copy link
Copy Markdown

@nikzanda 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 29, 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: a1b9b01e-3509-432e-ab94-9f028161489d

📥 Commits

Reviewing files that changed from the base of the PR and between 92957a1 and a617eea.

📒 Files selected for processing (3)
  • assets/index.less
  • src/utils/expandUtil.tsx
  • tests/ExpandRow.spec.jsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/utils/expandUtil.tsx
  • tests/ExpandRow.spec.jsx

Walkthrough

新增展开全部行功能。该功能支持默认或自定义图标、批量展开与收起、可展开行过滤、受控状态同步,以及自定义展开列表头。README 文档同步更新。

Changes

展开全部行支持

Layer / File(s) Summary
公开配置与图标渲染
src/interface.ts, src/utils/expandUtil.tsx
新增 RenderExpandAllIconPropsRenderExpandAllIconexpandAllIconshowExpandAllonExpandAll 配置。新增默认展开全部图标渲染函数。
展开状态与展开列
src/hooks/useExpand.ts, src/hooks/useColumns/index.tsx, src/Table.tsx
useExpand 管理可展开行、全选状态和批量处理器。Table 将展开全部数据传递给 useColumnsuseColumns 将展开全部图标传递给 columnTitle
集成与验证
tests/ExpandRow.spec.jsx, assets/index.less, README.md, README.zh-CN.md
测试覆盖默认、自定义、受控和标题场景。样式更新展开图标按钮。中英文文档新增配置说明。

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

Sequence Diagram(s)

sequenceDiagram
  participant Table
  participant useExpand
  participant useColumns
  participant renderExpandAllIcon
  Table->>useExpand: 获取展开全部状态和处理器
  useExpand-->>Table: 返回 expandAllInfo
  Table->>useColumns: 传递 expandAllIcon 和 expandAllInfo
  useColumns->>renderExpandAllIcon: 渲染展开全部图标
  renderExpandAllIcon->>useExpand: 触发展开或收起全部行
  useExpand-->>Table: 更新 expandedRowKeys
Loading

Suggested reviewers: zombiej

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 💡 1
🛠️ Fix failing CI checks 💡
  • Fix failing CI checks
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@nikzanda
nikzanda force-pushed the feat/expand-all-header branch from 22bede1 to ef33496 Compare July 31, 2026 10:18
@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.07%. Comparing base (08188d3) to head (a617eea).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1505      +/-   ##
==========================================
+ Coverage   99.05%   99.07%   +0.02%     
==========================================
  Files          45       45              
  Lines        1374     1413      +39     
  Branches      413      425      +12     
==========================================
+ Hits         1361     1400      +39     
  Misses         13       13              

☔ View full report in Codecov by Harness.
📢 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.

@nikzanda
nikzanda marked this pull request as ready for review July 31, 2026 10:20
@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.

@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.

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@src/utils/expandUtil.tsx`:
- Around line 57-64: Update the expand-all control in the rendered component
from a span to a native button with type="button", preserving its className and
onClick behavior. Add an aria-label that reflects the current expanded state and
bind aria-expanded to expanded. Extend the interaction tests to verify Tab focus
and activation via Enter and Space.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3313343f-3c8c-4313-babe-050aa6c7b4e7

📥 Commits

Reviewing files that changed from the base of the PR and between 08188d3 and ef33496.

📒 Files selected for processing (8)
  • README.md
  • README.zh-CN.md
  • src/Table.tsx
  • src/hooks/useColumns/index.tsx
  • src/hooks/useExpand.ts
  • src/interface.ts
  • src/utils/expandUtil.tsx
  • tests/ExpandRow.spec.jsx

Comment thread src/utils/expandUtil.tsx
@nikzanda

Copy link
Copy Markdown
Contributor Author

@afc163 @zombieJ, the implementation is now complete and this PR is ready for review.

It includes the expand-all API, controlled and uncontrolled behavior, rowExpandable filtering, keyboard accessibility, documentation, and regression tests. All modified and coverable lines are covered by tests, and CodeRabbit reports no remaining actionable comments.

When you have time, could you please review the proposed API and implementation? I’m happy to make any adjustments needed before proceeding with the Ant Design integration for ant-design/ant-design#8791. Thanks!

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