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

Form onFieldsChange stale values for allFields argument after Adding / Removing Form.List Items #28929

Closed
1 task done
Sean-Tay opened this issue Jan 19, 2021 · 1 comment
Closed
1 task done
Labels
❓FAQ issues would be discussed a lot

Comments

@Sean-Tay
Copy link

Sean-Tay commented Jan 19, 2021

  • 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. Open console.log.
  2. Add List Item.
  3. Check console.log for allFields (shows 5 items).
  4. Add another List Item.
  5. Check console.log for allFields (shows 7 items).
  6. Remove a List Item.
  7. Check console.log for allFields (shows 9 items).

What is expected?

  1. Open console.log.
  2. Add List Item.
  3. Check console.log for allFields (shows 7 items).
  4. Add another List Item.
  5. Check console.log for allFields (shows 9 items).
  6. Remove a List Item.
  7. Check console.log for allFields (shows 7 items).

What is actually happening?

  1. Open console.log.
  2. Add List Item.
  3. Check console.log for allFields (shows 5 items).
  4. Add another List Item.
  5. Check console.log for allFields (shows 7 items).
  6. Remove a List Item.
  7. Check console.log for allFields (shows 9 items).
Environment Info
antd 4.10.3
React 17.0.1
System Windows 10
Browser Chrome 87.0.4280.141

Might be related:
#28185
#28698

Background / Use-Case:
Disable Submit Button while Form has Errors. Was using onFieldsChange to check for Error State of each Field, but QA flag that when removing List Item containing all Errors in the Form, Submit Button was still disabled.

@Sean-Tay Sean-Tay changed the title Form getFieldsValue stale values for allFields argument after Adding / Removing Form.List Items Form onFieldsChange stale values for allFields argument after Adding / Removing Form.List Items Jan 19, 2021
@zombieJ
Copy link
Member

zombieJ commented Jan 27, 2021

It's not a bug. When add users list item, it changes the users first. And then React render new data as node which create the users.2.first and users.2.last node later. So when the onFieldsChange trigger, the new come Field is not come into the page yet. And patch new Field on page do not trigger onFieldsChange since nothing changed.

@zombieJ zombieJ added the ❓FAQ issues would be discussed a lot label Jan 27, 2021
@zombieJ zombieJ closed this as completed Jan 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
❓FAQ issues would be discussed a lot
Projects
None yet
Development

No branches or pull requests

2 participants