-
-
Notifications
You must be signed in to change notification settings - Fork 280
fix(Form): avoid merging sparse list patches into allValue #771
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@QDyanbing is attempting to deploy a commit to the React Component Team on Vercel. A member of the Team first needs to authorize it. |
Walkthrough本PR新增测试用例以验证Form.List字段更新时onValuesChange回调中allValues参数的正确性,同时更新@rc-component/util依赖版本至^1.6.2。 Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
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. Comment |
Summary of ChangesHello @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
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this 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 中获取了完整的最新数据,无需再次合并。合并逻辑仅为列表本身的直接操作(如添加、删除项)保留。
这个改动逻辑清晰,从根本上解决了问题。同时,新增的测试用例很好地覆盖了该场景,确保了修复的有效性。这是一个出色的修复。
|
试了下可以了,谢谢👍 |
|
onValueChange的问题应该是mergeWith的原因,需等@rc-component/util发布后升级 |
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
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.