Skip to content

Conversation

@QDyanbing
Copy link
Contributor

@QDyanbing QDyanbing commented Dec 17, 2025

fix ant-design/ant-design#56245

这里只补充了测试用例具体修复在 react-component/util#714

Summary by CodeRabbit

发布说明

  • 测试

    • 新增测试以确保更新列表项字段时,列表项顺序保持完整且其他项目保留正确。
  • 依赖更新

    • 更新工具库依赖版本,以支持更好的性能和稳定性。

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link

vercel bot commented Dec 17, 2025

@QDyanbing is attempting to deploy a commit to the React Component Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link

coderabbitai bot commented Dec 17, 2025

Walkthrough

本PR新增测试用例以验证Form.List字段更新时onValuesChange回调中allValues参数的正确性,同时更新@rc-component/util依赖版本至^1.6.2。

Changes

内聚块 / 文件 变更摘要
测试用例
tests/list.test.tsx
新增测试"should not drop list items when updating list item field",验证在Form.List项内更新嵌套字段时,onValuesChange提供的allValues参数是否正确包含所有项且顺序保持不变
依赖管理
package.json
将@rc-component/util依赖版本从^1.5.0升级至^1.6.2

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Poem

🐰 列表项不再逗丢失,
嵌套更新保序如初心,
依赖升级润物细无声,
allValues 完整又清晰,
Form的承诺得验证! 🎉

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR标题准确总结了主要变更,即避免将稀疏列表补丁合并到allValue,直接反映了问题的解决方案。
Linked Issues check ✅ Passed PR通过添加测试用例和升级@rc-component/util依赖至1.6.2版本来解决#56245,该版本包含了真实的修复,符合问题需求。
Out of Scope Changes check ✅ Passed 所有代码变更都在目标范围内,新增测试验证列表项更新时保留顺序,依赖更新为修复问题的必要版本。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0136afb and 36e0299.

📒 Files selected for processing (1)
  • package.json
✅ Files skipped from review due to trivial changes (1)
  • package.json

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 and usage tips.

@gemini-code-assist
Copy link

Summary of Changes

Hello @QDyanbing, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a critical data loss issue within the Ant Design Form.List component. Previously, modifying an item in a dynamic list that was not the last element could result in the unintended removal of other list items. The change refines the internal value merging mechanism to correctly handle updates within list structures, ensuring that all form data is consistently maintained.

Highlights

  • Form.List Data Loss Fix: Addressed a bug in Ant Design's Form.List where updating non-last items led to data loss.
  • Conditional Value Merging: Modified the FormStore's onValuesChange logic to conditionally merge values for list fields, ensuring proper data preservation.
  • New Test Case: Introduced a new test in list.test.tsx to validate that updating a list item does not inadvertently drop other items.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

这个 Pull Request 旨在修复在 Form.List 中更新非末尾项时导致数据丢失的问题。问题根源在于,即便是更新列表中的单个字段,旧代码也会尝试将一个稀疏的 changedValues 对象与 allValues 合并,而这个合并逻辑在处理稀疏数组时存在缺陷,会导致列表中部分数据丢失。

本次修复的方案是,当更新的只是列表内的一个字段时,不再执行合并操作。这是因为 allValues 此时已经从更新后的 store 中获取了完整的最新数据,无需再次合并。合并逻辑仅为列表本身的直接操作(如添加、删除项)保留。

这个改动逻辑清晰,从根本上解决了问题。同时,新增的测试用例很好地覆盖了该场景,确保了修复的有效性。这是一个出色的修复。

@ShenHongFei
Copy link

试了下可以了,谢谢👍

@QDyanbing
Copy link
Contributor Author

onValueChange的问题应该是mergeWith的原因,需等@rc-component/util发布后升级

@codecov
Copy link

codecov bot commented Dec 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.53%. Comparing base (d2ac4b8) to head (36e0299).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #771   +/-   ##
=======================================
  Coverage   99.53%   99.53%           
=======================================
  Files          19       19           
  Lines        1291     1291           
  Branches      324      324           
=======================================
  Hits         1285     1285           
  Misses          6        6           

☔ View full report in Codecov by Sentry.
📢 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.

@zombieJ zombieJ merged commit 31ef0b7 into react-component:master Dec 25, 2025
7 of 8 checks passed
@QDyanbing QDyanbing deleted the fix/mergevalue branch December 25, 2025 07:57
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.

Form.List 未包裹在 Form.Item 内时, Form 的 onValuesChange 回调中第二个参数 allValues 不正确

3 participants