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

field.move causes an error when applied to two objects with different fields #39

Closed
dekhanov opened this issue Sep 14, 2018 · 3 comments

Comments

@dekhanov
Copy link

dekhanov commented Sep 14, 2018

Bug report

What is the current behavior?

field.move causes an error at the getValidators function when applied to two objects with different fields

See the demo: https://codesandbox.io/s/x94j811oj4
Click a swap button

What is the expected behavior?

To swap objects with no error

What's your environment?

See the CodeSandBox link

@luishdz1010
Copy link

Any workaround]? I'm hitting this with nested array fields...

@HawiCaesar
Copy link

I managed to make a simple workaround borrowing from @dekhanov example. I think it can be made better though I still find it readable. Here is the demo.

This came with the inspiration of this blog. Credits to Erik Rasmussen for explaining the mutator concept to detail.

@dekhanov
Copy link
Author

Hi, @HawiCaesar! I,m afraid that what you have implemented is a swap mutator, not move.
There is no difference between them in the case of two elements, but it will not work correctly if the number of elements more then two.

@luishdz1010
To workaround the issue you can try the first implementation of the move mutator from here: final-form/final-form-arrays@4750506#diff-2dda6a27cd50646eb66a941de8781bcf

In this case you will face this issue: final-form/final-form-arrays#10
It's just a lesser of two evils.

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