-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Field component doesn't update model-value if it's initial value #4579
Comments
That is expected, you aren't doing the two-way binding here. You are always setting the <div id="app">
<Field
id="test"
name="test"
type="text"
:model-value="value" // 👈 Should be this
@update:model-value="onUpdate($event)"
/>
</div> |
@logaretm that hardcoded model-value was to simplify the example, in our big codebase, we have been relying on the previous behaviour and current one is breaking change. Following is to make this more clear: // reusable Input.vue
<script>
const props = defineProps({
modelValue?: string
})
const value = toRef(props, 'modelValue')
</script>
<Field
:model-value="value"
@update:model-value="$emit('update:model-value', $event)"
/> // other components
<script>
const valueFromServer = ref()
const newPayload = ref()
fetchData().then((data) => valueFromServer.value = data)
</script>
<Input
:model-value="valueFromServer"
@update:model-value="newPayload.value = $event"
/> With such structure, as long as |
The previous behavior you are referring to was a bug where If in your case there is a delay in getting the value to sync with the input, then you should be using a watcher to set the value to the new one. I understand it might be breaking in your case but that wasn't intended either. |
What happened?
Since v4.11.8
@update:model-value
isn't triggered if the value is what was initially given viamodel-value
. See repro steps.As a sidenote, v4.11.8 has fixed old problem that I commented here.
Reproduction steps
@update:model-value
trigger log@update:model-value
triggers any value except initial value of the field.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-radio-eabq7e?file=src%2FApp.vue
Code of Conduct
The text was updated successfully, but these errors were encountered: