Skip to content

fix(TreeSelect): preserve disabled child selection - #681

Merged
zombieJ merged 3 commits into
masterfrom
test-disabled-child-selection
Aug 4, 2026
Merged

fix(TreeSelect): preserve disabled child selection#681
zombieJ merged 3 commits into
masterfrom
test-disabled-child-selection

Conversation

@zombieJ

@zombieJ zombieJ commented Aug 4, 2026

Copy link
Copy Markdown
Member

Summary

  • preserve selected disabled child nodes when their parent is checked with SHOW_PARENT
  • add a controlled TreeSelect regression test for the disabled-child scenario

Root cause

SHOW_PARENT filtered every child whose parent was selected without considering whether the child itself was disabled. In a controlled TreeSelect, the emitted value therefore dropped the disabled child and cleared its selection on the next render.

Validation

  • ut test --runInBand (184 tests passed)
  • ut tsc
  • ut lint (0 errors; 6 existing warnings)

Related to ant-design/ant-design#16096

Summary by CodeRabbit

  • Bug 修复

    • 优化 SHOW_PARENT 选择策略:勾选父节点时,已选中的禁用子节点会继续保留。
    • 受控 TreeSelect 中将同时正确显示父节点及其禁用子节点,避免已选内容意外丢失。
  • 测试

    • 新增相关场景测试,覆盖父节点选择与禁用子节点保留行为。

@gemini-code-assist

Copy link
Copy Markdown

Caution

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

@vercel

vercel Bot commented Aug 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tree-select Ready Ready Preview Aug 4, 2026 7:40am

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

本次变更调整 SHOW_PARENT 策略,使禁用的当前实体继续保留,并新增受控 TreeSelect 测试,验证勾选父节点后同时保留父节点和禁用子节点。

Changes

SHOW_PARENT 保留逻辑

Layer / File(s) Summary
保留禁用选中值与受控场景验证
src/utils/strategyUtil.ts, tests/Select.checkable.spec.tsx
SHOW_PARENT 检查当前实体的禁用状态。受控 TreeSelect 测试验证勾选父节点后仍保留禁用子节点。

Estimated code review effort: 2 (简单) | ~10 分钟

Poem

我是小兔,轻敲选择树,
父节点勾选,子节点不迷路。
禁用叶子稳稳留下,
SHOW_PARENT 逻辑清楚。
两个选中项,一起跳舞。

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了修复内容,明确说明了保留 TreeSelect 中禁用子节点选择。
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test-disabled-child-selection

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.

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

React Doctor found no new issues. 🎉

Reviewed by React Doctor for commit b7c7af1.

@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.84%. Comparing base (f33bc66) to head (b7c7af1).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #681   +/-   ##
=======================================
  Coverage   99.84%   99.84%           
=======================================
  Files          17       17           
  Lines         629      633    +4     
  Branches      178      181    +3     
=======================================
+ Hits          628      632    +4     
  Misses          1        1           

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

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

❌ Deploy failed

PR preview ❌ Failed ❌ Failed
🔗 Preview https://react-component-tree-select-preview-pr-681.surge.sh (may be unavailable)
📝 Commitb7c7af1
🪵 LogsView logs
📋 Build log (last lines)
npm error
npm error Could not resolve dependency:
npm error peer eslint@"^3 || ^4 || ^5 || ^6 || ^7 || ^8 || ^9.7" from eslint-plugin-react@7.37.5
npm error node_modules/eslint-plugin-react
npm error   dev eslint-plugin-react@"^7.37.5" from the root project
npm error   eslint-plugin-react@"^7.32.2" from @umijs/fabric@4.0.1
npm error   node_modules/@umijs/fabric
npm error     @umijs/fabric@"^4.0.0" from rc-test@7.1.3
npm error     node_modules/rc-test
npm error       dev rc-test@"^7.1.3" from the root project
npm error
npm error Conflicting peer dependency: eslint@9.39.5
npm error node_modules/eslint
npm error   peer eslint@"^3 || ^4 || ^5 || ^6 || ^7 || ^8 || ^9.7" from eslint-plugin-react@7.37.5
npm error   node_modules/eslint-plugin-react
npm error     dev eslint-plugin-react@"^7.37.5" from the root project
npm error     eslint-plugin-react@"^7.32.2" from @umijs/fabric@4.0.1
npm error     node_modules/@umijs/fabric
npm error       @umijs/fabric@"^4.0.0" from rc-test@7.1.3
npm error       node_modules/rc-test
npm error         dev rc-test@"^7.1.3" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
npm error
npm error
npm error For a full report see:
npm error /home/runner/.npm/_logs/2026-08-04T07_41_30_188Z-eresolve-report.txt
npm error A complete log of this run can be found in: /home/runner/.npm/_logs/2026-08-04T07_41_30_188Z-debug-0.log

🤖 Powered by surge-preview

@zombieJ
zombieJ marked this pull request as ready for review August 4, 2026 07:23
@gemini-code-assist

Copy link
Copy Markdown

Caution

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

@zombieJ zombieJ changed the title fix: preserve disabled child selection fix(TreeSelect): preserve disabled child selection Aug 4, 2026
@zombieJ zombieJ added the bug label Aug 4, 2026
@zombieJ
zombieJ merged commit 96ffb62 into master Aug 4, 2026
15 checks passed
@zombieJ
zombieJ deleted the test-disabled-child-selection branch August 4, 2026 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant