logaretm / vee-validate

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

Custom component does not trigger change event on form #4725

Closed Fauphi closed 4 months ago

Fauphi commented 6 months ago

What happened?

My custom component that does use useField but no standard form elements like input, select,.. does not trigger the change event on the form. Validation works in the custom component.

Reproduction steps

  1. Start Demo Link
  2. Change the input field -> Alert box shows that the form has changed
  3. click on one of the circles of the custom element -> alert box does not show, but should

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/vee-validate-v4-custom-inputs-umelh5?file=src%2FApp.vue

Code of Conduct

TomDeSmet commented 6 months ago

Have you tried this: https://vee-validate.logaretm.com/v4/guide/composition-api/custom-inputs#v-model-support

logaretm commented 4 months ago

I don't think this was suggested in the docs anywhere. Form component does not emit any event besides the submit event and invalid-submit.

If you want to be notified of value changes, then consider using useForm and watching the values property.

const { values }  = useForm();

watch(values, () => {
  // Do something
}, { deep: true });