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

Validation breaks after unmounting of a duplicated field #3688

Closed
jedrzej-bridgemaker opened this issue Dec 13, 2017 · 3 comments · Fixed by #3756
Closed

Validation breaks after unmounting of a duplicated field #3688

jedrzej-bridgemaker opened this issue Dec 13, 2017 · 3 comments · Fixed by #3756

Comments

@jedrzej-bridgemaker
Copy link
Contributor

Are you submitting a bug report or a feature request?

This is a bug.

What is the current behavior?

When two fields for the same form value are rendered, then one of these fields is unmounted, validation stops to work.
For the provided sandbox:

  1. check that the validation is working for the field
  2. add another field (+ button) - validation is still working
  3. remove a field (- button) - validation is broken

In a more real-world scenario it occured to me when a part of the form was being re-rendered in a different branch of the DOM tree - 'new' fields get registered before old ones get unregistered, causing the error to occur.

What is the expected behavior?

Validation should work if there's a field rendered that requires it

Sandbox Link

https://www.webpackbin.com/bins/-L0ES7_aTU4kA-O9gsgc

What's your environment?

react 16,
redux-form 7.2.0

Other information

Probably need to check the count of the fields before removing the validators?
https://github.com/erikras/redux-form/blob/master/src/createReduxForm.js#L585

@jedwards1211
Copy link
Contributor

This is happening to me too due to animation. I have an animated transition in a wizard form between steps for entering single values and a final step where the user can review the entered values in a table. during the transition between the final step and the table, a duplicate of the field mounts before the field from the final step unmounts.

jedwards1211 added a commit to jedwards1211/redux-form that referenced this issue Jan 15, 2018
erikras pushed a commit that referenced this issue Jan 16, 2018
* test(reduxForm): add failing test

* test(reduxForm): fix failing test for validation after duplicate field unmount

* fix #3688
@erikras
Copy link
Member

erikras commented Jan 18, 2018

Published fix in v7.2.1.

@lock
Copy link

lock bot commented Jan 18, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants