You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: clean non-preserved list field by its current name - #815
The unregister callback cleaned the store using the name path captured at register time. After List.remove/move shifts a mounted field to another index, unmounting it with preserve={false} targeted the old path, so its value stayed in the store and came back on remount. The callback now reads the field's current name path.
Test: added a preserve case (remove the first row, then unmount the surviving row's preserve={false} field) that fails before and passes after. Full suite passes.
This fixes cleanup of non-preserved list field values after their index shifts. No merge-blocking risk was found.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
标题 “fix: clean non-preserved list field by its current name” 与变更内容一致。变更让 registerField 返回的注销回调在清理前读取字段当前的 namePath。新增测试覆盖列表删除首项后,非保留字段卸载时的值清理。标题准确说明了主要修复点:按当前名称清理非保留的列表字段。
Linked Issues check
[#814] 的核心需求是:字段因 List.move 或 List.remove 改变索引后,若以 preserve={false} 卸载,其值必须从 store 中清除。PR 将注销回调改为在清理前读取字段当前的 namePath(src/hooks/useForm.ts,+2 行)。注销时使用当前路径,可清除正确的 store 值,并避免使用注册时的旧路径。PR 也新增 tests/pres…
Out of Scope Changes check
PR 的改动集中在 registerField 注销回调的一处路径读取,以及 preserve 相关的一个回归测试。两者都直接服务于 #814 的 preserve={false} 在索引变化后残留值的问题,未发现无关改动。摘要中未列出其他源码或公共 API 声明变更。证据限制:未能直接核对 useForm.ts 的改动行,结论基于 AI 生成摘要与测试描述。
Full details: Linked Issues check
Explanation
[#814] 的核心需求是:字段因 List.move 或 List.remove 改变索引后,若以 preserve={false} 卸载,其值必须从 store 中清除。PR 将注销回调改为在清理前读取字段当前的 namePath(src/hooks/useForm.ts,+2 行)。注销时使用当前路径,可清除正确的 store 值,并避免使用注册时的旧路径。PR 也新增 tests/preserve.test.tsx 中的 'clean value by current name after index changed' 用例:删除首行后卸载保留项的 memo 字段,并断言完整表单值只保留 id。该用例对应 #814 的删除场景。证据限制:useForm.ts 的 diff 无法读取,文件读取在 registerField 之前被截断,因此改动行未被直接核对,判断基于 PR 摘要和测试描述。#814 中的移动(move)场景没有专门测试,但同一修复基于当前路径,理论上同样覆盖该场景。
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 299b0112-31cb-479d-921b-64311501654e
Commits
Reviewing files that changed from the base of the PR and between be0cc09 and a093028.
Files selected for processing: 2
src/hooks/useForm.ts
tests/preserve.test.tsx
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
close #814
The unregister callback cleaned the store using the name path captured at register time. After
List.remove/moveshifts a mounted field to another index, unmounting it withpreserve={false}targeted the old path, so its value stayed in the store and came back on remount. The callback now reads the field's current name path.Test: added a preserve case (remove the first row, then unmount the surviving row's
preserve={false}field) that fails before and passes after. Full suite passes.Summary by CodeRabbit