useFieldArray push with custom component using useField mutates pushed object #4372
Closed
2 of 5 tasks
Labels
🐛 bug
Unintended behavior
What happened?
When using the
push
function fromuseFieldArray
in combination with a custom component using theuseField
helpers it seems to cause an issue whereby the pushed object is modified directly, so any subsequent pushes contain the modified values. It's a little hard to describe, so I've setup a reproduction: https://stackblitz.com/edit/vitejs-vite-oqwnxq?file=src%2FApp.vueIf you add a new row and enter something then add another row, the newest row will have the same values as the previous row.
If you instead push a clone of the object it appears to work fine, though I'm not sure that this is intended. Please let me know if you need any more details or if I'm doing something very wrong.
Reproduction steps
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/edit/vitejs-vite-oqwnxq?file=src%2FApp.vue
Code of Conduct
The text was updated successfully, but these errors were encountered: