You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Provide a prop value but no @update handler for a v-model prop on a child component using defineModel.
To reproduce in the example, click the middle "Toggle Child" button.
What is expected?
Props are not typically considered writable, and defineModel emulates a prop/$emit pair, so writes to the value should not have a (direct) effect. Since the parent component has provided a value, that value is the one that should be used. This demonstrates what I think is the expected behavior, since this is how v-models are documented to work under the hood.
Omitting the update event handler should tell the child component that the parent does not care if the child wants to update the value, and the event/update should be ignored.
What is actually happening?
After initialization, the value behaves like a local ref, and ignores the value provided by the parent, unless it changes.
This is actually designed this way, but missing in the docs. We'll make sure to amend the docs accordingly. I'll leave this open until we have done that.
I'm having the same issue where I'm using Cypress component testing, but the emitted function provided by @vue/test-utils isn't catching the emitted value.
Vue version
3.4.15
Link to minimal reproduction
https://play.vuejs.org/#eNqlVUlP20AU/itT9wBI2FZFL01NRFkOrdQWAerJl4nnxRmYTbMEUJT/3jfjJNghLBI3z1u/721eZD+MKeYBslFWucZy44kDH8y4VlwabT1ZEAtTsiRTqyXZQ9O97xvdmZZmpSjK+Iihor5WjVbOoytlWonHS6sNOY6R9r0NcIAmQ4PfmoHYsqjKDhFiwYcHaQT1gC9CKmeoGl9SC8oTLbn3XLXExCwo4RbEI3pHm2Q9saTsvhLi1fckeK8VYdzRiQA2vtFtK4B0UauyUw8CPEuNGeecxdyRRAdgTkUAUoEkzj8KOK6zRgttRxZYnY33T0NLriCV77oBRS3XB1UJcvwKYPTtyoTB+iWtsy0uJ43gzd2WFZb109DrY1R7LKliJBiGbSEz/BZgX2Exz2Xs8i4yqf1vs1lPyYbOyu8dfKqyN0DZYdZNcC6pKW6dVjj/i2herxSuzkYkSaIMpzq+62zmvXGjsmyYQjfMzee2UOBLZWR5gmalDTh/EnKm5clR8bX48q3EAfN9eQFO5hOr7x1YjFJnh708JQrnYHMkwsCCfW/eLbdB7i3ds/wx/bJWSyyLd7iXU95uFaXB/nHs7l/jOe7toDhUCH3/K8ni5m7INDNo7nbIb91DR+rSQkLWK4CntgXfqS+u/8ADfm+UOD1BrBrxgvIKnBYhYuzMTkMayp5dQvsz9Rhn+cZdPHhQbk0qAk3VSPapIXF0X6L+BPeoOOpVcX0Kd1zV4dnDWWYw5QrSIO8/TToiJgtU0SB8B2v51knkygS/81SkxSL/4sYi+MVavES0gy19ae36G/e0bGczLlhv1wYbhs90/eJ/JOJKsPIULFVvQpu71mpsT95dR/L5/PwcGSImJJlcs+V/MAJIzg==
Steps to reproduce
Provide a prop value but no
@update
handler for av-model
prop on a child component usingdefineModel
.To reproduce in the example, click the middle "Toggle Child" button.
What is expected?
Props are not typically considered writable, and
defineModel
emulates aprop
/$emit
pair, so writes to the value should not have a (direct) effect. Since the parent component has provided a value, that value is the one that should be used.This demonstrates what I think is the expected behavior, since this is how
v-model
s are documented to work under the hood.Omitting the update event handler should tell the child component that the parent does not care if the child wants to update the value, and the event/update should be ignored.
What is actually happening?
After initialization, the value behaves like a local ref, and ignores the value provided by the parent, unless it changes.
System Info
Any additional comments?
No response
The text was updated successfully, but these errors were encountered: