Skip to content

fix: clear Transfer selection on one-way removal - #59428

Merged
QDyanbing merged 1 commit into
ant-design:masterfrom
yunfeizhu:fix/transfer-one-way-remove-selection
Sep 29, 2026
Merged

QDyanbing merged 1 commit into
ant-design:masterfrom
yunfeizhu:fix/transfer-one-way-remove-selection

Conversation

@yunfeizhu

Copy link
Copy Markdown
Contributor

🤔 This is a ...

  • 🐞 Bug fix
  • ✅ Test Case

🔗 Related Issues

Fixes #59427

💡 Background and Solution

In one-way Transfer, removing a right-side item clears the internal right-side selection but does not call onSelectChange. With controlled selectedKeys, the parent is never told to clear that selection, so the removed item appears checked after it moves to the left list.

Notify onSelectChange when the right-side selection is non-empty, using the existing handleSelectChange path before onChange. Keep the no-selection case silent. This matches the regular move path without changing the public API.

The minimal reproduction uses released antd 6.6.5. I verified in the browser that after removing B, targetKeys becomes [], while selectedKeys remains ["b"] and B is checked on the left.

Verification:

  • Transfer tests: 12 suites, 145 tests, 48 snapshots passed.
  • TypeScript, Biome, ESLint, and git diff --check passed.

📝 Change Log

Language Changelog
🇺🇸 English 🐞 Fix controlled Transfer selection remaining checked after one-way removal.
🇨🇳 Chinese 🐞 修复单向穿梭框移除条目后,受控选中状态仍保持勾选的问题。

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

Copy link
Copy Markdown
Contributor

Preview is ready

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

👁 Visual Regression Report for PR #59428 Passed ✅

🎯 Target branch: master (9820ea7)
⚠️ Baseline may be stale: no snapshot for the PR's base commit was found, so an older branch snapshot was used. Some diffs below may come from changes already merged into master rather than this PR.
📖 View Full Report ↗︎
📖 Alternative Report ↗︎

🎊 Congrats! No visual-regression diff found.

📖 中文报告

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

🎯 目标分支: master (9820ea7)
⚠️ 基线可能已过期: 未找到该 PR 基准提交对应的快照,因此回退使用了较旧的分支快照。下方部分差异可能来自已合并到 master 的改动,而非本 PR。

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

@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

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: 5f51715d-25b9-4300-a2c8-09f5a574f7db

📥 Commits

Reviewing files that changed from the base of the PR and between f703ed1 and 10de719.

📒 Files selected for processing (2)
  • components/transfer/__tests__/index.test.tsx
  • components/transfer/index.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

  • 问题修复
    • 移除右侧项目时,仅在右侧存在已选中项的情况下通知选择状态变更。
    • 移除项目后,相关复选框会取消选中,变更回调会收到正确的方向和项目键。

Walkthrough

单向 Transfer 移除右侧项目时,只有存在右侧选中项才触发 onSelectChange。测试覆盖无选中项时不触发回调,以及受控选中项被移除后清除选中状态的情况。

Changes

Transfer 选中状态

Layer / File(s) Summary
单向移除与选中状态清除
components/transfer/index.tsx, components/transfer/__tests__/index.test.tsx
右侧存在选中项时,移除操作会调用 onSelectChange 清除右侧选中状态;测试验证无选中项时不触发该回调,并验证受控状态下移除项目后选中状态同步清除。

Priority: ⬇️ Low

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

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: li-jia-nan

Merge Risk: ⚪ Minimal · up to 10de7

The change appears ready to merge after normal checks; no actionable risk remains from this review.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 10de7

The change corrects controlled selection behavior without adding a new interface or expanding component authority. The main design consideration is the ordering of the two existing callbacks during removal.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The observable change reaches Transfer consumers through UI selection and removal callbacks; the examined path does not add privileged reachability or a sensitive sink.

Trust Boundaries and Controls

  • inferred — The parent still owns controlled selection and target state; the added notification does not transfer authorization or enforcement authority to the component.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed 标题准确概括了本次变更:修复单向 Transfer 移除项目时未清除选中状态的问题。标题简洁且与主要改动一致。
Description check ✅ Passed 描述明确说明了问题、解决方案、测试结果和关联 Issue。内容与代码变更直接相关。
Linked Issues check ✅ Passed PR 实现了 Issue #59427 的编码要求。onRightItemRemove 仅在右侧存在选中项时通过现有 handleSelectChange 路径触发 onSelectChange('right', []),然后继续触发 onChange。新增受控状态测试验证移除项移动到左侧、右侧选择清空、回调仅触发一次、复选框取消选中。无选中项时的静默行为也有测试覆盖。
Out of Scope Changes check ✅ Passed 变更仅涉及 Transfer 的单向移除选择同步,以及对应的自动化测试。变更保持公共 API 不变,并直接支持 Issue #59427 的受控选择修复。未发现与该目标无关的代码或文件变更。
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

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

我是小兔,蹦到 Transfer 旁,
轻轻点下移除按钮忙。
选中的小球收进行囊,
回调告诉大家它已离场。
复选框安静地暗了光,
我抱胡萝卜跳过月亮。

Comment @coderabbitai help to get the list of available commands.

@coderabbitai
coderabbitai Bot requested a review from li-jia-nan September 29, 2026 10:04
@pkg-pr-new

pkg-pr-new Bot commented Sep 29, 2026

Copy link
Copy Markdown
More templates

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

commit: 10de719

@codecov

codecov Bot commented Sep 29, 2026

Copy link
Copy Markdown

Bundle Report

Changes will decrease total bundle size by 5.79MB (-64.1%) ⬇️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
antd.min-array-push 3.24MB -5.79MB (-64.1%) ⬇️

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 (New) 1.81MB 1.81MB 100.0% 🚀
antd.min.js (New) 1.43MB 1.43MB 100.0% 🚀
antd-with-locales.js (Deleted) -4.82MB 0 bytes -100.0% 🗑️
antd.js (Deleted) -4.21MB 0 bytes -100.0% 🗑️

@codecov

codecov Bot commented Sep 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (f703ed1) to head (10de719).

Additional details and impacted files
@@            Coverage Diff            @@
##            master    #59428   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          834       834           
  Lines        16050     16052    +2     
  Branches      4215      4216    +1     
=========================================
+ Hits         16050     16052    +2     

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

@QDyanbing QDyanbing left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@QDyanbing
QDyanbing merged commit 3ad130b into ant-design:master Sep 29, 2026
43 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🎉 Thank you for your contribution! If you have not yet joined our DingTalk community group, please feel free to join us (when joining, please provide the link to this PR).

🎉 感谢您的贡献!如果您还没有加入钉钉社区群,请扫描下方二维码加入我们(加群时请提供此 PR 链接)。

钉钉社区群二维码

@chenshuai2144 chenshuai2144 mentioned this pull request Oct 12, 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.

Transfer: one-way removal leaves controlled right-side selection behind

2 participants