Skip to content

fix: correct Table selection menu scope - #59570

Merged
afc163 merged 1 commit into
ant-design:masterfrom
yunfeizhu:fix/table-selection-menu-scope
Oct 14, 2026
Merged

afc163 merged 1 commit into
ant-design:masterfrom
yunfeizhu:fix/table-selection-menu-scope

Conversation

@yunfeizhu

Copy link
Copy Markdown
Contributor

中文版模板 / Chinese template

🤔 This is a ...

  • 🆕 New feature
  • 🐞 Bug fix
  • 📝 Site / documentation improvement
  • 📽️ Demo improvement
  • 💄 Component style improvement
  • 🤖 TypeScript definition improvement
  • 📦 Bundle size optimization
  • ⚡️ Performance optimization
  • ⭐️ Feature enhancement
  • 🌐 Internationalization
  • 🛠 Refactoring
  • 🎨 Code style optimization
  • ✅ Test Case
  • 🔀 Branch merge
  • ⏩ Workflow
  • ⌨️ Accessibility improvement
  • ❓ Other (about what?)

🔗 Related Issues

Fixes #59569

Minimal reproduction on StackBlitz · Standalone source

💡 Background and Solution

This fixes two scope inconsistencies in Table's built-in selection menu:

  1. Invert current page iterates only the top-level page records, leaving tree descendants unchanged. Use the existing flattened current-page data so enabled descendants are inverted as well. Disabled rows and selections on other pages remain unchanged.
  2. Clear all data checks disabled state only in the current page's checkbox map. As a result, a selected disabled row is preserved when clearing from its own page but deselected when clearing from another page. Resolve selected records through the existing record/cache lookup and disabled-state helper. Missing records are guarded before calling getCheckboxProps.

The changes are limited to useSelection and its existing tests; there are no public API or styling changes.

Regression coverage includes nested descendants, custom childrenColumnName, repeated inversion, disabled descendants, selections on another page, clearing from either page, preserved records, and missing keys. With the new tests applied to the unmodified base implementation, four cases fail; all five new cases pass with this fix.

Screenshots

Both screenshots show the tree table after inversion and the paged table on page 2 after clearing from page 1. The first uses published [email protected]; the second uses this branch's source.

Before After
Before: child selection is not inverted and the disabled row is cleared After: child selection is inverted and the disabled row remains selected

Narrow viewport: before / after.

Verification

  • Full Table suite: 17 suites passed, 463 tests passed, 17 skipped, 166 snapshots passed.
  • TypeScript check, Biome and ESLint checks for both changed files, npm run compileOnly, and git diff --check passed.
  • Browser checks using the same reproduction at 1100 px and 390 px confirmed both failures before the fix and the expected behavior afterward, including clearing from both pages. No page errors were reported.
  • Simulated merge into the current feature branch completed without conflicts; this PR targets master.

📝 Change Log

Language Changelog
🇺🇸 English 🐞 Fix Table selection menu skipping tree descendants when inverting selection and clearing disabled rows on other pages.
🇨🇳 Chinese 🐞 修复 Table 选择菜单反选时遗漏树形子节点,以及清空选择时取消其他页禁用行选中状态的问题。

Invert current-page tree descendants and preserve disabled selections when clearing across pages. Cover custom child fields, repeated inversion, preserved records, and missing keys.
@bolt-new-by-stackblitz

Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

👁 Visual Regression Report for PR #59570 Passed ✅

🎯 Target branch: master (463a6ad)
📖 View Full Report ↗︎
📖 Alternative Report ↗︎

🎊 Congrats! No visual-regression diff found.

📖 中文报告

👁 PR #59570 视觉回归报告 通过 ✅

🎯 目标分支: master (463a6ad)

🎊 恭喜!未发现视觉回归差异。

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Preview is ready

@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9b8ef964-26d6-4165-8c64-fcf39e50d1df
📥 Commits

Reviewing files that changed from the base of the PR and between 463a6ad and 3c321df.

📒 Files selected for processing: 2
  • components/table/__tests__/Table.rowSelection.test.tsx
  • components/table/hooks/useSelection.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📝 Summary

Summary by CodeRabbit

  • Bug 修复
    • 修复表格反选操作,使其覆盖当前页中的嵌套记录,同时保留禁用项和其他页的选中项。
    • 修复清除选择时的记录处理:保留禁用项,并确保回调记录与数据源中实际存在的选中记录一致。

表格行选择逻辑现会在当前页反选时遍历嵌套记录。清除选择时,仍存在且复选框禁用的已选记录会被保留。新增测试覆盖树形数据、分页和 preserveSelectedRowKeys 场景。

Changes: 表格行选择

Layer / File(s) Summary
选择菜单范围与记录保留
components/table/hooks/useSelection.tsx, components/table/__tests__/Table.rowSelection.test.tsx
反选操作遍历当前页的扁平化数据,包含嵌套记录。清除选择时仅保留仍存在且复选框禁用的记录。测试覆盖 children 和 nodes 子节点字段、分页,以及 preserveSelectedRowKeys 场景。

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: qdyanbing

Merge Risk: ⚪ Minimal · up to 3c321

The selection-menu fix is mergeable after normal checks; no unresolved issue is established.

Pre-merge checks: Passed 5
Passed Passed checks: 5 passed
Check name Status Explanation
Title check Passed 标题“fix: correct Table selection menu scope”准确概括了本次修复的主要内容,即修正 Table 选择菜单的作用范围。
Description check Passed 描述说明了两个选择菜单问题、修复方案、测试覆盖范围和验证结果,与变更内容直接相关。
Linked Issues check Passed 直接关联的开放问题 #59569 要求两项修复。useSelection.tsx 的 SELECTION_INVERT 现在遍历 flattedData,因此覆盖当前页的树形后代,并继续通过复选框属性跳过禁用行。SELECTION_NONE 现在通过 getSelectedRecord 和 isCheckboxDisabled 检查已选记录,并跳过缺失记录。新增测试覆盖 `…
Out of Scope Changes check Passed 变更仅涉及 components/table/hooks/useSelection.tsx 和其现有测试文件。生产代码修复选择菜单行为,测试直接验证 #59569 的两个缺陷。未发现公共 API、样式或无关功能变更。
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

🔧 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 requested a review from QDyanbing October 14, 2026 08:35
@codecov

codecov Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Bundle Report

Changes will increase total bundle size by 32 bytes (0.0%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
antd.min-array-push 3.24MB 32 bytes (0.0%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: antd.min-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
antd-with-locales.min.js 16 bytes 1.81MB 0.0%
antd.min.js 16 bytes 1.43MB 0.0%

@pkg-pr-new

pkg-pr-new Bot commented Oct 14, 2026

Copy link
Copy Markdown
More templates

npm i https://pkg.pr.new/antd@59570

commit: 3c321df

@codecov

codecov Bot commented Oct 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (463a6ad) to head (3c321df).

Additional details and impacted files
@@            Coverage Diff            @@
##            master    #59570   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          833       833           
  Lines        16052     16052           
  Branches      4211      4212    +1     
=========================================
  Hits         16052     16052           

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

@afc163
afc163 merged commit 90eaecc into ant-design:master Oct 14, 2026
43 checks passed
@MadCcc MadCcc mentioned this pull request Oct 19, 2026
1 of 17 tasks
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.

Table selection menu skips tree descendants and clears disabled rows across pages

2 participants