-
-
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
base: master
Are you sure you want to change the base?
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修复了 Form.List 字段值合并逻辑,移除了 mergeWith 中的自定义 prepareArray 回调,使列表字段能正确合并而非被替换为空数组。修改了 updateValue 函数对列表字段的处理方式,确保 onValuesChange 回调中的 allValues 参数包含完整的列表项。 Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 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 (2)
🧰 Additional context used🧬 Code graph analysis (1)tests/list.test.tsx (2)
🔇 Additional comments (2)
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 中获取了完整的最新数据,无需再次合并。合并逻辑仅为列表本身的直接操作(如添加、删除项)保留。
这个改动逻辑清晰,从根本上解决了问题。同时,新增的测试用例很好地覆盖了该场景,确保了修复的有效性。这是一个出色的修复。
|
试了下可以了,谢谢👍 |
fix ant-design/ant-design#56245
修复更新form-list非最后一项数据导致的数据丢失问题
Summary by CodeRabbit
发布说明
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.