logaretm / vee-validate

✅ Painless Vue forms
https://vee-validate.logaretm.com/v4
MIT License
10.82k stars 1.27k forks source link

The PR #4710 causes side effects #4929

Open LionelVallet opened 6 days ago

LionelVallet commented 6 days ago

What happened?

Context I have a list of contacts and a contact form. When I select a contact, I reset a form with the selected contact values. An autosave is triggered by form meta change.

The contact schema contains some object array properties (e.g. addresses). When I reset the form (by selecting a contact) from a contact with addresses to a contact with no address, addresses key is deleted, form is marked dirty, it triggers the autosave. That is my first problem. From this point of view, its not a fix from a minor version update, it's a breaking change. Mark the form as dirty when you reset it twice with different values, where there is no user interaction with form inputs makes no sense.

Then there is a second problem. After this situation occurs (reset with an object containing an array with values and then an array without values), the adresses part of the form is completely broken. Changes on addresses field are not detected, i can push new ones, edit, etc. this no longer affects form meta. Whereas a modification to another field on the form works. I need to reload the page and select the contact with no addresses first to add a new address.

I need to stay in version 4.14.3 to avoid this behavior.

Reproduction steps

Use version 4.14.4 or higher (#4678) (#4710) Reset a form with an object containing an array with values and then with an object containing the same array without values.

Version

Vue.js 3.x and vee-validate 4.x

What browsers are you seeing the problem on?

Relevant log output

No response

Demo link

https://stackblitz.com

Code of Conduct

logaretm commented 6 days ago

That is my first problem. From this point of view, its not a fix from a minor version update, it's a breaking change.

I understand, that happens often and happened to me with Vue itself many times. There is no way to tell if someone is relying on a bug or not so this can't be considered a breaking change.

Can you please create a minimal reproduction of both issues?

LionelVallet commented 5 days ago

I tried : https://stackblitz.com/edit/vitejs-vite-mfho5f?file=src%2Fcomponents%2FHelloWorld.vue&terminal=dev

But I can't reproduce and I can't tell the difference for now. In this example, I expected that selecting contact 2 and then contact 1 would mark the meta dirty, because the “addresses” key must be deleted, if I've understood correctly, since the array is empty.

I'm sorry I can't come up with a clear explanation.