final-form / react-final-form-arrays

A component for rendering and editing arrays 🏁 React Final Form
MIT License
205 stars 70 forks source link

When using "push" and then "remove" the form stays dirty. #34

Open 311chaos opened 6 years ago

311chaos commented 6 years ago

Are you submitting a bug report or a feature request?

I believe this is a bug, but it is possible that I am not understanding something.

What is the current behavior?

When using a FieldArray, push, and remove you can end up with a dirty form, when I don't think it should be dirty.

I forked the Simple Demo: https://codesandbox.io/s/32p402x3om

The form stays dirty, but I would expect it to be back to pristine.

What is the expected behavior?

Sandbox Link

https://codesandbox.io/s/32p402x3om

What's your environment?

React Final form. Mac OSX Chrome.

Other information

Thank you for a great library. Let me know if I can provide more information.

maciejmyslinski commented 6 years ago

Howdy!

Thank you for reporting an issue! 👍

Could you please double check if the demo you provided works as you'd expect? I can't see add customer button anywhere 😞

Thanks!

titenis commented 5 years ago

This bug still persist with versions:

"final-form": "4.18.2",
"final-form-arrays": "3.0.1",
"react-final-form": "6.3.0",
"react-final-form-arrays": "3.1.0",

on form.mutators.remove('emails', 0); second element becomes first one and becomes dirty, which is wrong