Replies: 3 comments 4 replies
|
Vuetify 3 doesn't expose a The asymmetry you're hitting: a text field also bubbles the native DOM Uniform pattern — listen to <v-select v-model="form.role" :items="roles" @update:model-value="onCommit('role', $event)" />
<v-text-field v-model="form.name" @update:model-value="onCommit('name', $event)" />For menu inputs it fires exactly on commit. Text fields fire on every keystroke; if you want them to commit only on blur (to match the selects), pair it with <v-text-field
v-model="form.name"
@update:focused="(f) => { if (!f) onCommit('name', form.name) }"
/>And since Vue custom events don't bubble to the form, there's no single form-level |
|
Yes, I understand what's currently happening. The |
|
@ray007 Right, that is the real gap. Vuetify 3 has no form level "committed" event, and you are correct that none of the component's custom events bubble. The way around it is to stop using the Vue events for this and lean on the native DOM So for anything backed by a real input or textarea (VTextField, VTextarea, number fields) you get form level listening with one handler: <div @change="onCommit">
<v-form>
<v-text-field name="email" v-model="email" />
<v-textarea name="notes" v-model="notes" />
</v-form>
</div>function onCommit(e) {
// e.target is the native input that just committed
console.log('committed', e.target.name, e.target.value)
}Vuetify forwards The one input that emits no native <v-select name="country" :items="items" v-model="country"
@update:model-value="v => onCommit({ target: { name: 'country', value: v } })" />One caveat if you reach for VAutocomplete or VCombobox: those inputs are editable, so they do fire a native Net result is one I checked this on Vuetify 3.12: a text field fires |
Uh oh!
There was an error while loading. Please reload this page.
I'm used to all inputs (string, number, select, ...) to emit a bubbling
changeevent, when the user actually commits a new value.Unfortunately, this is not the case when building a form with
vuetify.Especially inputs with a menu do not emit a
changeevent.Am I the only one missing this?
Or is there an easy code-pattern to add the event back to all
v-select,v-combobox,v-autocomplete, ... instances ?All reactions