Skip to content

fix: clear stale Transfer selection when key type changes - #59166

Merged
zombieJ merged 2 commits into
masterfrom
fix-transfer-key-selection
Sep 11, 2026
Merged

zombieJ merged 2 commits into
masterfrom
fix-transfer-key-selection

Conversation

@QDyanbing

Copy link
Copy Markdown
Member

🤔 这个变动的性质是?

  • 🆕 新特性提交
  • 🐞 Bug 修复
  • 📝 站点、文档改进
  • 📽️ 演示代码改进
  • 💄 组件样式/交互改进
  • 🤖 TypeScript 定义更新
  • 📦 包体积优化
  • ⚡️ 性能优化
  • ⭐️ 功能增强
  • 🌐 国际化改进
  • 🛠 重构
  • 🎨 代码风格优化
  • ✅ 测试用例
  • 🔀 分支合并
  • ⏩ 工作流程
  • ⌨️ 无障碍改进
  • ❓ 其他改动(是关于什么的改动?)

🔗 相关 Issue

None

💡 需求背景和解决方案

Transfer 使用数据源 key 集合的签名清理已不存在的非受控选中状态。原实现直接使用分隔符拼接 key,数字 1 与字符串 '1' 会得到相同签名,导致数据源在两种 key 之间切换后旧选中状态重新出现。

本次通过同时序列化 key 的类型和值来区分不同类型,并避免含分隔符的字符串产生签名碰撞;同时添加回归测试。不涉及公开 API 变更。

📝 更新日志

语言 更新描述
🇺🇸 英文 🐞 Fix Transfer restoring stale selections after data source key types change.
🇨🇳 中文 🐞 修复 Transfer 在数据源 key 类型变化后恢复旧选中状态的问题。

@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 Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

👁 Visual Regression Report for PR #59166 Passed ✅

🎯 Target branch: master (77d8317)
📖 View Full Report ↗︎
📖 Alternative Report ↗︎

🎊 Congrats! No visual-regression diff found.

📖 中文报告

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

🎯 目标分支: master (77d8317)

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

@github-actions

github-actions Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Preview is ready

@coderabbitai

coderabbitai Bot commented Aug 31, 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: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 65004153-89b5-4bcc-9e51-c200726a26a4

📥 Commits

Reviewing files that changed from the base of the PR and between c99d71d and 2a9abf3.

📒 Files selected for processing (2)
  • components/transfer/__tests__/index.test.tsx
  • components/transfer/hooks/useSelection.ts

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


📝 Summary

Summary by CodeRabbit

  • Bug 修复

    • 修复 Transfer 组件中数据项键值类型变化时,旧选中状态未被清除的问题。
    • 现在可正确区分数字键与字符串键,避免出现错误的选中状态。
  • 测试

    • 新增相关测试,覆盖键值类型切换后选中状态被重置的场景。

Walkthrough

Transfer 现在可以区分字符串键和数字键。选中状态会在键类型变化后清除。新增测试覆盖字符串键与数字键之间的切换。

Changes

Transfer 选中状态

Layer / File(s) Summary
按键类型重置选中状态
components/transfer/hooks/useSelection.ts, components/transfer/__tests__/index.test.tsx
flattenKeys 使用键类型和值生成依赖标识。新增测试验证键类型从字符串切换为数字后,过期选中状态会被清除。

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

Merge Risk: ⚪ Minimal · up to 19fb6

This change prevents stale Transfer selections from reappearing when data-source key types change and adds regression coverage. No actionable merge-blocking risk remains beyond normal checks and review.

Suggested reviewers: li-jia-nan

Poem

小兔检查键类型,
字符数字分得清。
旧的选中轻轻落,
新的列表更安静。
测试跳过青草坡。

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed 描述准确说明了 Transfer 选中状态在数据源 key 类型变化后重新出现的问题,并说明了修复方案和回归测试。
Title check ✅ Passed 标题明确概括了在 key 类型变化时清除 Transfer 过期选中状态这一主要变更。
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.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-transfer-key-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.

@coderabbitai
coderabbitai Bot requested a review from li-jia-nan August 31, 2026 02:24
@github-actions

github-actions Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
dist/antd.min.js 442.56 KB (+5 B 🔺)
dist/antd-with-locales.min.js 526.04 KB (+3 B 🔺)

@codecov

codecov Bot commented Aug 31, 2026 •

Copy link
Copy Markdown

Bundle Report

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

Detailed changes
Bundle name Size Change
antd.min-array-push 3.22MB 60 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 30 bytes 1.79MB 0.0%
antd.min.js 30 bytes 1.43MB 0.0%

@pkg-pr-new

pkg-pr-new Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
More templates

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

commit: 19fb633

@codecov

codecov Bot commented Aug 31, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (77d8317) to head (19fb633).

Additional details and impacted files
@@            Coverage Diff            @@
##            master    #59166   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          834       834           
  Lines        15992     15992           
  Branches      4203      4203           
=========================================
  Hits         15992     15992           

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

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 31, 2026 •

Copy link
Copy Markdown

Deploying ant-design with  Cloudflare Pages  Cloudflare Pages

Latest commit: 19fb633
Status: ✅  Deploy successful!
Preview URL: https://1af98086.ant-design.pages.dev
Branch Preview URL: https://fix-transfer-key-selection.ant-design.pages.dev

View logs

@nrps9909 nrps9909 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed exact head 2a9abf30b88d100a9ab9539cdefc7e64e9c5d1a1.

I reproduced the regression causally: applying only the new test to base c99d71d06c fails on the second number → string → number key-type transition, while the exact PR head passes the full Transfer suite (53 tests / 5 snapshots). I also checked 289 independently generated signatures covering numeric/string distinctions and delimiter/escaping inputs; no collisions were found. ESLint, Biome, git diff --check, and the current remote checks are green.

AI assistance disclosure: Codex was used to inspect the diff, run the base-vs-head reproduction, generate the adversarial signature probe, and draft this review. I independently verified the exact head and results.

@zombieJ zombieJ 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. The typed JSON signature distinguishes numeric and string keys without delimiter collisions, and the regression coverage verifies stale Transfer selections are cleared across key-type changes.

@zombieJ
zombieJ merged commit 32da294 into master Sep 11, 2026
47 checks passed
@zombieJ
zombieJ deleted the fix-transfer-key-selection branch September 11, 2026 03:10
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.

3 participants