ITADN

fix: preserve dirty/touched meta on late mount (#5072)

#5145Pull Requestlogaretm 创建于 2026-03-04
L
logaretmcommented
## Summary - Fixes #5072: Field "dirty" meta lost after child component mounted for the first time - When `setFieldValue` changes a field's value before the field's host component mounts, the dirty and touched meta flags are now preserved when the component finally mounts and `useField` runs - Two changes: - **`useFieldState.ts`**: Skip calling `stageInitialValue` when the form already has an initial value for the path and no explicit `modelValue` was provided. This prevents overwriting the original initial value with the current (dirty) value. - **`useForm.ts`**: In `createPathState`, preserve the `touched` flag from any pre-existing path state (e.g., one created by `setFieldValue`) when creating a new path state for the same path. ## Test plan - [x] Added test: preserves dirty meta when field component mounts after programmatic value changes - [x] Added test: preserves touched meta when field component mounts after programmatic changes - [x] All existing 357 tests pass (3 pre-existing import failures in i18n/rules/validate packages are unrelated) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
合并状态:未合并 3 条评论