Skip to content
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

[Bug Report] ArrayField删除行时,多次删除同一行,由于field顺序导致对字段的操作顺序不对 #4130

Open
1 task
johnwojtek opened this issue Apr 8, 2024 · 0 comments

Comments

@johnwojtek
Copy link

johnwojtek commented Apr 8, 2024

  • I have searched the issues of this repository and believe that this is not a duplicate.

Reproduction link

Edit on CodeSandbox

Steps to reproduce

ArrayField name为array,其中一行为Input,其name为a2,用onFieldValueChange建立对array.*.a2的依赖。

添加5行数据,在a2那一列每行填入数据。然后持续删除index 为0的那一行。

What is expected?

直到删除所有行,也不会触发onFieldValueChange的回调。

What is actually happening?

第一次删除,不会触发onFieldValueChange的回调。第二次删除就会触发,之后每次删除这一行都会触发。

在spliceArrayState中对需要删除的行的字段进行操作,在each函数里,第一次删除后,所有字段在form.fields中的顺序有问题,导致生成的对field得操作也不对。比如删除array.0. *,删除后,新的array.0. *会被挪到最后,第二次删除array.0. *,生成的操作就是先将array.1. * update 到array.0. *,最后才是remove array.0. * 的操作。

Package

@formily/core@2.3.1


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant