-
-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Description
Vue version
3.4.21
Link to minimal reproduction
Steps to reproduce
There are two inputs in the playground.
<MyInput :modelValue="staticMessage" @update:modelValue="emptyFn"/>
and
<MyInput :modelValue="staticMessage"/>
MyInput
is a simple input
that shows the current value, and is using defineModel
for it's modelValue
.
- Change
first
component input in preview tab - Change
second
component input in preview tab - See that
first
instance ofMyInput
does not update and the second does update.
What is expected?
First instance of MyInput
should behave exactly like the second one.
What is actually happening?
We're adding a simple event listener, which is passive and like any other event listener should be appended to other listeners, but instead is somehow causing the inner modelValue
to be fixated on the initial static value.
For example, when I don't use onMounted
hook as an way to listen to mount event, I don't expect the component to never be mounted. this is an event listener, hooking into a fixed behavior, whether I listen to it or not.
This is the same scenario here.
System Info
System:
OS: Linux 6.6 Ubuntu 22.04.2 LTS 22.04.2 LTS (Jammy Jellyfish)
CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12700H
Memory: 7.24 GB / 15.35 GB
Container: Yes
Shell: 5.8.1 - /usr/bin/zsh
Binaries:
Node: 20.11.0 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/bin/yarn
npm: 10.2.4 - /usr/local/bin/npm
pnpm: 8.15.1 - /usr/local/bin/pnpm
bun: 1.0.25 - ~/.bun/bin/bun
Any additional comments?
I'm not sure if this is intentional or not. I've cheeked every related defineModel
issue but this is not similar to other issues (open or closed) here.
The usecase is replacing useVModel
with defineModel
for wrapper components where a default
(model) value is provided to a self-controlled child component, meaning the child controls it's model value (synced with parent) without introducing another defaulModelValue
prop.
More context: radix-vue