Subscribe on changes!

Changes to unrelated ref causes v-model.lazy input to reset

avatar
Jul 23rd 2021

Version

3.1.5

Reproduction link

https://codesandbox.io/s/recursing-keller-edvtl?file=/package.json

Steps to reproduce

See codesandbox example for minimum reproduction. Within this example, there's a setInterval running that increments the 'count' ref every one second. We also have a input bound to 'someNumber' using v-model.lazy.

If you begin typing into the input, you'll see that every time the interval ticks, it causes the input to reset it's value to that of the someNumber value.

What is expected?

Asynchronous changes to unrelated refs should not cause a lazily bound input to reset to it's v-model value.

What is actually happening?

Changes to an unrelated ref is causing lazily bound inputs to reset any in-progress changes back to the bound ref's value

avatar
Mar 2nd 2022

This issue states "changes to unrelated refs should not cause a lazily bound input to reset". But currently changes to related refs are not working too. I guess this is related to the fix in ac74e1dd33a45874a96fc13efdaade613c44dd70. Is this expected? If so, maybe we should update the doc to mention this.

<script setup>
import { ref } from 'vue'

const msg = ref('not computed yet')
</script>

<template>
  <input v-model.lazy="msg" @focus="msg = 'result'">
</template>

The input value would not change if I focus it.