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

move and swap only affect values, not field state #10

Closed
dallonf opened this issue Jul 6, 2018 · 6 comments
Closed

move and swap only affect values, not field state #10

dallonf opened this issue Jul 6, 2018 · 6 comments

Comments

@dallonf
Copy link

dallonf commented Jul 6, 2018

Are you submitting a bug report or a feature request?

I believe this is a bug.

What is the current behavior?

Here is a version of of the React Final Form Arrays example, modified to have validation errors that only appear when a field has been touched:

https://codesandbox.io/s/8k623wrrz9

  1. Click "Add Customer"
  2. Click in the "First Name" field, type something in (ex. "Homer")
  3. Click in the "Last Name" field, but do not type in it
  4. Click "Add Customer" again (Red text "Required" will appear under Customer 1's Last Name)
  5. Click in Customer 2's "First Name" field, type something different (ex. "Marge")
  6. Do not click in Customer 2's "Last Name" field.
  7. Click the "Swap first two" button

The names have changed, but the "Required" error message is still in the same place (or, depending on your perspective, has moved to a different customer).

What is the expected behavior?

I would expect the "touched" state to move along with the field, so that in this example the error would still be attached to Homer's last name, even though Homer has moved.

What's your environment?

Other information

The demo shows this happening with swap, but I originally observed the behavior with move.

@311chaos
Copy link

I have a similar issue.

@dallonf - Did you come up with a work-around of any sorts?

There is also a similar discussion over on the react-final-form-arrays repo.

final-form/react-final-form-arrays#36

@erikras - I am not sure how to track this down through all the repos. I have followed it from react-final-form-arrays to final-form-arrays to changeValue in final-form. I am not sure if this is a bug, or if it is intended.

Is there any way to have the meta move with the input?

@erikras
Copy link
Member

erikras commented Aug 22, 2018

Great reporting, @dallonf.

@erikras
Copy link
Member

erikras commented Aug 22, 2018

I have confirmed this is a bug and have made some progress on it, but not yet conquered it. Stay tuned.

@311chaos
Copy link

Thanks for the update @erikras. I really appreciate your time.

@erikras
Copy link
Member

erikras commented Aug 23, 2018

Published fix in v1.1.0.

Sandbox with updated dep:

Edit 🏁 React Final Form - Field Arrays

carlhueffmeier added a commit to carlhueffmeier/final-form-arrays that referenced this issue Nov 27, 2018

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
During move and swap, the field state of the source field was copied to
the target field. The field state, however, contained functions that had
a reference to the previous position. This caused changes to be applied
to the wrong field.

Resolves: final-form#15
See also: final-form#10
erikras pushed a commit that referenced this issue Dec 10, 2018

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
During move and swap, the field state of the source field was copied to
the target field. The field state, however, contained functions that had
a reference to the previous position. This caused changes to be applied
to the wrong field.

Resolves: #15
See also: #10
@erikras
Copy link
Member

erikras commented Dec 10, 2018

Published fix in v1.1.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

3 participants