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

fix(v-model): fix the lazy modifier is not reset by other modifications #8547

Merged
merged 7 commits into from
May 31, 2024
9 changes: 7 additions & 2 deletions packages/runtime-dom/src/directives/vModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ export const vModelText: ModelDirective<
mounted(el, { value }) {
el.value = value == null ? '' : value
},
beforeUpdate(el, { value, modifiers: { lazy, trim, number } }, vnode) {
beforeUpdate(
el,
{ value, oldValue, modifiers: { lazy, trim, number } },
vnode
) {
el[assignKey] = getModelAssigner(vnode)
// avoid clearing unresolved text. #2302
if ((el as any).composing) return
Expand All @@ -93,7 +97,8 @@ export const vModelText: ModelDirective<
}

if (document.activeElement === el && el.type !== 'range') {
if (lazy) {
// #8546
if (lazy && value === oldValue) {
return
}
if (trim && el.value.trim() === newValue) {
Expand Down