Skip to content
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

defineModel behavior without parent passing v-model different between strings and arrays #11720

Open
danielkellyio opened this issue Aug 26, 2024 · 2 comments
Labels
need documentation Not necessarily a bug, but proper documentation is needed

Comments

@danielkellyio
Copy link

Vue version

3.4.38

Link to minimal reproduction

https://stackblitz.com/edit/vitejs-vite-9pbycg?file=src%2FApp.vue,src%2Fcomponents%2FMyArrayComponent.vue,src%2Fcomponents%2FMyStringComponent.vue&terminal=dev

Steps to reproduce

  1. use defineModel in a child component to define some array data (call it model)
  2. alter model by pushing a new array item to it

What is expected?

Template to re-render with new item in the array

What is actually happening?

template does not re-render

System Info

No response

Any additional comments?

Replacing the entire array works as expected but pushing does not. Maybe this is intended (not deep)?
If so, perhaps the docs should include a note about this.

Thanks!

@edison1105
Copy link
Member

This is the intended behavior. The model is a custom ref and only triggers when .value is replaced.

@edison1105 edison1105 added the need documentation Not necessarily a bug, but proper documentation is needed label Aug 27, 2024
@dabernathy89
Copy link

I don't understand where the "intended behavior" is defined, as the original RFC didn't mention the limitation that only primitives would be supported. This feels more like a bug to me; if defineModel creates a ref why shouldn't it behave like a standard ref? And why would the behavior be different when v-model is provided vs not provided?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need documentation Not necessarily a bug, but proper documentation is needed
Projects
None yet
Development

No branches or pull requests

4 participants
@dabernathy89 @edison1105 @danielkellyio and others