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

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

vercelBot commented Aug 4, 2026

Copy link
Copy Markdown

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

ProjectDeploymentActionsUpdated (UTC)
tree-selectReadyReadyPreviewAug 4, 2026 7:40am

@coderabbitai

coderabbitaiBot 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 nameStatusExplanation
Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
Description Check✅ PassedCheck 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-actionsBot commented Aug 4, 2026

Copy link
Copy Markdown

React Doctor found no new issues. 🎉

Reviewed by React Doctor for commit b7c7af1.

@codecov

codecovBot 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-actionsBot commented Aug 4, 2026

Copy link
Copy Markdown

❌ Deploy failed

PR preview ❌ Failed❌ Failed
🔗 Previewhttps://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.

@zombieJzombieJ changed the title fix: preserve disabled child selectionfix(TreeSelect): preserve disabled child selectionAug 4, 2026
@zombieJzombieJ added the bug label Aug 4, 2026
@zombieJ
zombieJ merged commit 96ffb62 into masterAug 4, 2026
15 checks passed
@zombieJ
zombieJ deleted the test-disabled-child-selection branch August 4, 2026 07:42
aibayanyu20 added a commit to antdv-next/vue-components that referenced this pull request Aug 12, 2026
Scanned all 43 configured upstreams. The other 38 carried only
`ci: fix React Doctor workflow` commits (verified to touch `.github/`
only) and version bumps, so nothing to port there.
select:
- allow clearing the value via keyboard (react-component/select#1247).
The clear button was already ported as an accessible <button>, but
BaseSelect's Enter/Space handler preventDefault()-ed the native
activation, so the click never fired.
table:
- support `forceRender` on expandable rows (rc-table 1.11.0), for both
the plain and virtual body.
- stop mutating the object returned by `column.onCell()`, the remaining
gap from react-component/table#1488. The hover rowSpan part of that
PR was already covered locally by 0365d60.
- fix `Table.EXPAND_COLUMN` identity checks against Vue reactive
proxies. `toRaw()` is now used before comparison: previously a
`ref()`/`reactive()` column list made every `=== EXPAND_COLUMN` check
fail, which both auto-inserted a second expand column at index 0 and
rendered the user's sentinel as a phantom empty column.
tree:
- support `autoExpand` in `scrollTo`, plus the new `useTree` hook
exposing `getPath` (react-component/tree#1061).
`autoExpand` is guarded at the call site rather than inside
`setExpandedKeys`, so the guard reverted in 5fe098f is not
reintroduced.
- add `-treenode-unselectable` class for non-checkable, non-selectable
nodes (react-component/tree#1066).
- add characterization tests pinning controlled `expandedKeys`
behaviour, which deviates from upstream at three call sites as a
consequence of 5fe098f.
tree-select:
- preserve disabled child selection under SHOW_PARENT
(react-component/tree-select#681).
virtual-list:
- resolve `scrollTo({ key })` against the latest data and retry after a
data update (react-component/virtual-list#376, #377). An unresolved
key no longer scrolls the list to the top.
Also adds the missing `@v-c/select` path alias, which unblocks
`tree-select/tests/OptionList.test.tsx` (previously failing to collect),
and registers @rc-component/listy as an upstream — it is already in
sync at 1.2.3.
Test suite: 785 passing (was 750), 26 pre-existing failures unchanged
(steps, collapse, mutate-observer, cascader).
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for freeto 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

@zombieJ