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] invoking form.setValues in FormStep results the different scenarios #3148

Closed
1 task done
haoliangwu opened this issue May 26, 2022 · 1 comment
Closed
1 task done

Comments

@haoliangwu
Copy link

haoliangwu commented May 26, 2022

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

Reproduction link

Edit on CodeSandbox

Steps to reproduce

  1. fill out the first step and click next button
  2. then click back button

What is expected?

the input field with the name aaa should be empty because I invoke form.setValues in App.tsx@69.

What is actually happening?

the input field with the name aaa persisted with the previous value and the field.value has changed to it.

Package

@formily/[email protected]
@formily/[email protected]


Although I am not using FormStep directly, I implemented a similar one according to its source code and found this issue(maybe not).

After debugging, I found the root cause is as following:

The reason I don't ensure whether this behavior is an issue is maybe it is designed deliberately, anyway, if we invoke form.setValues with non-empty values, it works as expected.

In this case, I think it is a little bit confusing for an empty string. Sometimes, the empty string also has a special meaning at the business level, maybe we should not fallback it simply by isEmpty assertion.

Note: I found similar issues, eg #2901, #2629 but not sure they are same.

@janryWang
Copy link
Collaborator

This logic of restoring the scene by default is specially designed. If you want not to go to the cache, you can call reset or manually clear the cache.

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

2 participants