Skip to content

fix: honor rowExpandable for tree data - #1508

Open
nrps9909 wants to merge 1 commit into
react-component:masterfrom
nrps9909:codex/honor-tree-row-expandable
Open

fix: honor rowExpandable for tree data#1508
nrps9909 wants to merge 1 commit into
react-component:masterfrom
nrps9909:codex/honor-tree-row-expandable

Conversation

@nrps9909

@nrps9909 nrps9909 commented Aug 26, 2026

Copy link
Copy Markdown

Summary

  • apply rowExpandable to nested tree rows, including expand icons and row-click behavior
  • prevent controlled expanded keys and defaultExpandAllRows from revealing children of non-expandable rows
  • treat empty children arrays as non-expandable and cover standard and virtual tables

Verification

  • exact base: 7977f2b45a501728dddf0853466c1a013a7190dc
  • regression before the fix: tests/ExpandRow.spec.jsx -t "honors rowExpandable for tree data" failed because blocked-child was rendered
  • pnpm test — 21 files, 239 tests passed
  • pnpm tsc — passed
  • pnpm lint — 0 errors, 23 pre-existing warnings
  • pnpm compile — passed
  • git diff --check — passed

Fixes #1416

AI assistance disclosure: Codex was used to trace the tree expansion paths, implement the fix, and draft tests. The behavior was reproduced on the exact base before implementation, and all listed checks were run locally.

Summary by CodeRabbit

  • Bug Fixes
    • 修复树形表格中 rowExpandable 配置未完全生效的问题。
    • 不可展开的行不再显示展开内容或递归处理子节点。
    • defaultExpandAllRows 现在仅展开符合条件的行。
    • 虚拟表格与普通表格的行展开行为保持一致。
  • Tests
    • 新增并完善多级树形数据、虚拟表格及受限展开场景的测试。

@vercel

vercel Bot commented Aug 26, 2026

Copy link
Copy Markdown

@nrps9909 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 Aug 26, 2026

Copy link
Copy Markdown
Contributor

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: a79de19e-3c55-41a9-ae2d-06ceb2a42f23

📥 Commits

Reviewing files that changed from the base of the PR and between 7977f2b and 249942c.

⛔ Files ignored due to path filters (1)
  • tests/__snapshots__/ExpandRow.spec.jsx.snap is excluded by !**/*.snap
📒 Files selected for processing (9)
  • src/Body/index.tsx
  • src/VirtualTable/BodyGrid.tsx
  • src/hooks/useExpand.ts
  • src/hooks/useFlattenRecords.ts
  • src/hooks/useRowInfo.tsx
  • src/utils/expandUtil.tsx
  • tests/ExpandRow.spec.jsx
  • tests/Table.spec.jsx
  • tests/Virtual.spec.tsx

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


Walkthrough

Changes

rowExpandable 现在控制普通表格和虚拟表格中的树形记录展平、行展开状态及默认展开键。新增测试覆盖允许展开、禁止展开和空子节点场景。

行级展开条件

Layer / File(s) Summary
记录展平与组件接入
src/Body/index.tsx, src/VirtualTable/BodyGrid.tsx, src/hooks/useFlattenRecords.ts
Body 和 Grid 从 TableContext 获取 rowExpandableuseFlattenRecords 在递归展平前检查该函数,并在依赖变化时重新计算。
行状态与默认展开键
src/hooks/useRowInfo.tsx, src/utils/expandUtil.tsx, src/hooks/useExpand.ts
只有满足 rowExpandable 且具有非空子节点的记录才启用嵌套展开。defaultExpandAllRows 跳过不可展开记录及其子树。
树形与虚拟表格测试
tests/ExpandRow.spec.jsx, tests/Table.spec.jsx, tests/Virtual.spec.tsx
测试验证行点击、默认展开、间隔图标、虚拟表格展平结果和多级树形数据。

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

Merge Risk: ⚪ Minimal · up to 24994

This change narrows tree-row expansion, icon, and row-click behavior to honor rowExpandable, with regression coverage for standard and virtual tables. No actionable merge-blocking risk remains beyond normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant TableBody
  participant useFlattenRecords
  participant rowExpandable
  participant RowRenderer
  TableBody->>useFlattenRecords: 传入树形数据和 rowExpandable
  useFlattenRecords->>rowExpandable: 检查记录是否可展开
  rowExpandable-->>useFlattenRecords: 返回 true 或 false
  useFlattenRecords-->>RowRenderer: 返回过滤后的展平记录
  RowRenderer-->>TableBody: 渲染展开行或间隔图标
Loading

Suggested reviewers: zombiej, nikzanda

Poem

小兔捧来展开键,
树枝先问能否展。
允许枝头孩子现,
禁止节点留空隙。
虚拟表格步步稳,
测试月光照全程。

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 9 files. 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 标题“fix: honor rowExpandable for tree data”准确概括了本次 PR 的主要变更,内容简洁且明确。
Linked Issues check ✅ Passed PR 满足问题 #1416 的主要要求:树形数据支持 rowExpandable,自定义逻辑可以控制行展开,rowExpandable 返回 false 时隐藏展开图标并阻止展开,空 children 数组视为不可展开。代码同时覆盖了受控展开、defaultExpandAllRows、行点击行为、标准表格和虚拟表格。被排除的快照文件仅用于测试输出,不影响需求验证。
Out of Scope Changes check ✅ Passed 所有代码和测试变更都直接服务于树形数据中的 rowExpandable 支持。未发现与问题 #1416 无关的功能或范围外修改。
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 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.

@codecov

codecov Bot commented Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.09%. Comparing base (7977f2b) to head (249942c).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1508   +/-   ##
=======================================
  Coverage   99.08%   99.09%           
=======================================
  Files          45       45           
  Lines        1428     1436    +8     
  Branches      433      440    +7     
=======================================
+ Hits         1415     1423    +8     
  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.

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.

rowExpandable does not work when dataSource has children field

1 participant