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(runtime-dom): prevent unnecessary updates in v-model checkbox when value is unchanged #12146

Merged
merged 3 commits into from
Oct 11, 2024

Conversation

jh-leong
Copy link
Member

@jh-leong jh-leong commented Oct 10, 2024

close #12144

In the browser, the event order for an input click is click -> change.

When the click event has side effects, vModelCheckbox's beforeUpdate hook updates el.checked based on the old binding, causing it to reset incorrectly. The change event then updates the binding with the wrong value, leading to the issue.

This PR ensures el.checked is only updated when the binding changes, fixing a 3.5 regression and restoring 3.4 behavior.

NOTE: This PR only addresses cases where the value is neither an array nor a set (issue #8638 is still unhandled).

Copy link

github-actions bot commented Oct 10, 2024

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 101 kB (+47 B) 38.2 kB (+14 B) 34.3 kB (+19 B)
vue.global.prod.js 160 kB (+47 B) 58.1 kB (+18 B) 51.6 kB (+12 B)

Usages

Name Size Gzip Brotli
createApp (CAPI only) 49.2 kB 19 kB 17.3 kB
createApp 55.8 kB 21.5 kB 19.6 kB
createSSRApp 59.8 kB 23.2 kB 21.1 kB
defineCustomElement 60.6 kB 23.1 kB 21 kB
overall 69.5 kB 26.6 kB 24.2 kB

Copy link

pkg-pr-new bot commented Oct 10, 2024

Open in Stackblitz

@vue/compiler-core

pnpm add https://pkg.pr.new/@vue/compiler-core@12146

@vue/compiler-sfc

pnpm add https://pkg.pr.new/@vue/compiler-sfc@12146

@vue/compiler-dom

pnpm add https://pkg.pr.new/@vue/compiler-dom@12146

@vue/compiler-ssr

pnpm add https://pkg.pr.new/@vue/compiler-ssr@12146

@vue/reactivity

pnpm add https://pkg.pr.new/@vue/reactivity@12146

@vue/runtime-core

pnpm add https://pkg.pr.new/@vue/runtime-core@12146

@vue/runtime-dom

pnpm add https://pkg.pr.new/@vue/runtime-dom@12146

@vue/server-renderer

pnpm add https://pkg.pr.new/@vue/server-renderer@12146

@vue/shared

pnpm add https://pkg.pr.new/@vue/shared@12146

@vue/compat

pnpm add https://pkg.pr.new/@vue/compat@12146

vue

pnpm add https://pkg.pr.new/vue@12146

commit: 6e77a7f

@jh-leong
Copy link
Member Author

/ecosystem-ci run

@vue-bot
Copy link
Contributor

vue-bot commented Oct 10, 2024

📝 Ran ecosystem CI: Open

suite result latest scheduled
language-tools failure failure
nuxt success success
pinia success success
primevue success success
quasar success success
radix-vue success success
router success success
test-utils success success
vant success success
vite-plugin-vue success success
vitepress success success
vue-i18n success success
vue-macros success success
vuetify success success
vueuse success success
vue-simple-compiler success success

@skirtles-code
Copy link
Contributor

Potentially a fix for #8638.

@skirtles-code
Copy link
Contributor

I think this fix may suffer from a similar problem to #8639:

@edison1105 edison1105 added ready to merge The PR is ready to be merged. scope: v-model ❗ p4-important Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf. and removed ready to merge The PR is ready to be merged. labels Oct 11, 2024
@jh-leong jh-leong marked this pull request as draft October 11, 2024 02:06
@jh-leong jh-leong force-pushed the fix/12144 branch 2 times, most recently from cd9d697 to ab185e8 Compare October 11, 2024 05:57
@jh-leong jh-leong marked this pull request as ready for review October 11, 2024 05:58
@yyx990803 yyx990803 merged commit ea943af into vuejs:main Oct 11, 2024
13 checks passed
@jh-leong jh-leong deleted the fix/12144 branch October 11, 2024 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
❗ p4-important Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf. scope: v-model
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clicking on checkbox with @click-handler that impacts other checkbox will not check the clicked checkbox
5 participants