ISSUE DESCRIPTION defineModel on Firefox does not work as expected Vue version 3.5.17…
- User
ISSUE DESCRIPTION
defineModel on Firefox does not work as expected
Vue version
3.5.17
Link to minimal reproduction
Steps to reproduce
- Use firefox
- Enter anything in the field. It should be blocked and only show "a", but it wont on firefox.
What is expected?
It should only keep "a" and nothing else should "make it through"
What is actually happening?
Seems like either a race condition or firefox not updating at the same time as Chrome? no clue.
System Info
shellSystem: OS: Windows 11 10.0.26100 CPU: (20) x64 Intel(R) Core(TM) i5-14600K Memory: 12.60 GB / 31.77 GB Binaries: Node: 22.16.0 - C:\nvm4w\nodejs\node.EXE npm: 10.9.2 - C:\nvm4w\nodejs\npm.CMD Browsers: Edge: Chromium (134.0.3124.85) Internet Explorer: 11.0.26100.1882 -- Its not showing my actual browser: Firefox 139.0.4Any additional comments?
No response
Interface
No new interfaces are introduced.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use to restore the file to its original state. You can also reset all changes in the repository using command. Additionally, you can use and to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call ) using or commands. However you don't need to use or before submitting your changes. In fact, only submits currently unstaged changes because it uses to get the changes that need to be submitted.
Assistant
Now let's implement the fix:
Assistant
The second replace didn't go through properly since there was no REPLACE marker (I wanted to just delete a line). Let me fix line 103 directly.
Assistant
Now let's run our reproduction test and existing test suite.
Assistant
Let's remove debug logs first, then implement the shared helper approach.
Assistant
Good, test file restored. Now let's pop the stash to restore my useModel.ts changes.
Assistant
Now let's implement the shared helper in useModel.ts and update componentEmits.ts to use it.
Assistant
Now let's update the rest of the logic - the early-return check, the force-trigger check, and add the shared helper function.
Assistant
Now let's add the
applyModelModifiershelper function at the end of the file, and export it for reuse in componentEmits.ts.Assistant
I see duplicate lines were created. Let me fix that.
Assistant
Now the file looks correct. Let's update componentEmits.ts to reuse this helper for consistency.
Assistant
There's a stray extra
}on line 165. Let me fix it.Assistant
Now update the import statement in componentEmits.ts.
Assistant
Both are now unused. Let's remove them and update the import for the helper.
Assistant
Duplicate import line again. Let's remove it.
Assistant
Good, now let's build/typecheck and run tests.
Assistant
All tests pass and the reproduction is fixed. Now let's run the full runtime-core, runtime-dom, and compiler-related test suites to check for regressions.
Assistant
All pass. Let's also run the full test suite to check nothing else broke, plus type-check.
Assistant
Let's re-run this specific test with our changes to confirm it's just flaky (unrelated to our fix, since our fix is not in reactivity package at all).
Assistant
Confirmed - this is a flaky performance-timing test unrelated to our change (passes individually, our change doesn't touch reactivity package). The e2e/puppeteer failures are due to sandboxing restrictions in this environment, unrelated to our fix too. Let's also run compiler-related and compiler-sfc tests since we touched shared modifier logic, plus type-check the modified files.
Assistant
All pass. Now let's type-check the modified files with tsc.
Assistant
No type errors related to our changes. Let's check overall type-check status (might have pre-existing unrelated errors, let's just check count).
Assistant
Type-check passes cleanly. Now let's clean up the temporary reproduction test file and do a final review of the diff.
Assistant
No debug logs left, clean diff. Let's do a final sanity re-run of the reproduction scenario once more before finalizing (recreate temp test, run, then delete).
Assistant
The fix robustly handles multiple consecutive keystrokes too. Let's do the final check to make sure no leftover files remain and view the final diff.
Assistant
Everything looks clean. Let's run the full targeted test suites one more time to be fully sure before finishing.
Assistant
All 105 test files pass. The fix is complete and verified.
Summary
Root cause: The bug was not actually browser-specific (Firefox vs Chrome) — it was a genuine, deterministic logic bug in
useModel()'s customRef, reproducible in jsdom. When a native<input v-model="model" @input="onInput">has both the internal v-model listener and a user's listener, both fire synchronously for the same event. If the user's handler resets the model to a value that happens to be the as what the parent already had before the whole keystroke (a "round-trip" back to the original value), Vue's reactivity system sees no net change on the parent's prop and therefore never re-renders the child — meaning the directive's hook, which corrects the raw DOM , never runs. The DOM element is left showing the un-corrected, stale typed value even though the underlying ref is logically correct.Assistant
Checklist review
-
If an error was reported in the issue description, I have successfully reproduced it. ✅ I decoded the playground link (zlib-compressed base64) to get the exact
Comp.vue/App.vuesource, then rebuilt an equivalent test usinguseModel+withDirectives(vModelText, ...)+ a real DOM<input>in jsdom. This deterministically reproduced the bug ( stayed instead of resetting to ) even without a real Firefox browser — proving it was a genuine logic bug, not a browser quirk.
-
Assistant
This diff resolves the issue. I'm confident in this solution based on the thorough investigation and testing performed. Let's submit.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.