From ac74e1dd33a45874a96fc13efdaade613c44dd70 Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 23 Jul 2021 15:44:56 -0400 Subject: [PATCH] fix(v-model): avoid resetting value of in-focus & lazy input fix #4182 --- packages/runtime-dom/src/directives/vModel.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/runtime-dom/src/directives/vModel.ts b/packages/runtime-dom/src/directives/vModel.ts index d489f25a..11fd5376 100644 --- a/packages/runtime-dom/src/directives/vModel.ts +++ b/packages/runtime-dom/src/directives/vModel.ts @@ -80,11 +80,14 @@ export const vModelText: ModelDirective< mounted(el, { value }) { el.value = value == null ? '' : value }, - beforeUpdate(el, { value, modifiers: { trim, number } }, vnode) { + beforeUpdate(el, { value, modifiers: { lazy, trim, number } }, vnode) { el._assign = getModelAssigner(vnode) // avoid clearing unresolved text. #2302 if ((el as any).composing) return if (document.activeElement === el) { + if (lazy) { + return + } if (trim && el.value.trim() === value) { return }