fix(core): avoid arrayField spliceArrayState removing unexcepted fields#4323
Open
voderl wants to merge 1 commit into
Open
fix(core): avoid arrayField spliceArrayState removing unexcepted fields#4323voderl wants to merge 1 commit into
voderl wants to merge 1 commit into
Conversation
|
|
Open
6 tasks
hezhengxu2018
added a commit
to hezhengxu2018/silver-formily
that referenced
this pull request
Jul 21, 2026
官方仓库迁移的pr closed alibaba/formily/pull/4323
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Before submitting a pull request, please make sure the following is done...
masterorformily_next.npm test).npm run lint) - we've done our best to make sure these rules match our internal linting guidelines.Please do not delete the above content
What have you changed?
修复 ArrayField 状态转置非预期的情况。
比如一个数组有以下字段 array.0 array.1 array.2
在移除第一个元素时,会触发 array.0 的移除,array.1 -> array.0 array.2 -> array.1
在这一步中 address array.0 会先被 delete 再添加,字段遍历顺序会变更。
再次执行移除第一个元素,此时会先遍历 array.1 再遍历 array.0,这一步会触发 array.1 -> array.0 ,delete array.0
导致所有字段被删除。
修复方法:
在状态转置中,将删除 field 和删除 field 的 address 分成两种情况处理,field 被删除时可能其 address 不会被删除。
分开处理两种情况,第一种只删除 field 不删除 address,第二种只删除 address。
确保 address 顺序不变,同时确保这里的执行结果和遍历顺序无关。