Description
What happened?
I have a use case where I'm resetting a single field that's being handled by a useFieldArray
, when I use resetForm it's cleared like it should (along with other fields and their errors, which I'm trying to avoid), but in this particular use case I need to only clear said field and it's errors with resetField
, however, what resetField('array')
does right now is just clear the each value while retaining the number of elements in the array and it's errors, resetField('array', {value: undefined})
does the trick, but it keeps the errors.
I managed to make it work with a hacky reset function and exposing it to the parent component with defineExpose, something like
const reset = () => {
const shallowCopy = [...fields.value];
for(const field of shallowCopy) {
remove(fields.value.indexOf(field));
}
};
But I was thinking maybe the resetField approach is not behaving like it should, or at least it's not consistent with resetForm
Reproduction steps
- Have a form with useForm, have it define resetForm and resetField
- Have an array with useFieldArray and some simple validation (must check if it's a string for example)
- Try to reset the form programatically, it's expected behavior
- Try to reset the field 'array' programatically, it only reset fields and not errors
https://stackblitz.com/edit/vite-jrpjdat4
Version
Vue.js 3.x and vee-validate 4.x
What browsers are you seeing the problem on?
- Firefox
- Chrome
- Safari
- Microsoft Edge
Relevant log output
Demo link
https://stackblitz.com/edit/vite-jrpjdat4
Code of Conduct
- I agree to follow this project's Code of Conduct