fix(VNumberInput): prevent input changes when readonly#22692
Merged
J-Sek merged 1 commit intovuetifyjs:masterfrom Mar 7, 2026
Merged
fix(VNumberInput): prevent input changes when readonly#22692J-Sek merged 1 commit intovuetifyjs:masterfrom
J-Sek merged 1 commit intovuetifyjs:masterfrom
Conversation
When a user selects text in a readonly VNumberInput and types a non-digit character, the onBeforeinput handler would fire, calculate an empty/null potentialNewNumber, and then set inputText.value to that value — effectively clearing the model even though the field is readonly. Fix by returning early from onBeforeinput when controlsDisabled (readonly or disabled) is true, consistent with how toggleUpDown, clampModel, formatInputValue, and trimDecimalZeros already guard against mutations. Fixes vuetifyjs#22677
J-Sek
approved these changes
Mar 7, 2026
J-Sek
pushed a commit
that referenced
this pull request
Mar 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When a user selects text in a readonly
VNumberInputand types a non-digit character (e.g. a space or letter), theonBeforeinputhandler would still fire. Inside that handler, when the typed character doesn't match the allowed pattern, the code calls:This inadvertently sets
inputTextto an empty string, which the computed setter interprets as clearing the value (model.value = null), breaking thereadonlycontract.Fix
Add an early return at the top of
onBeforeinputwhencontrolsDisabled(readonly or disabled) istrue. This is consistent with howtoggleUpDown,clampModel,formatInputValue, andtrimDecimalZerosalready guard against mutations.Changes
VNumberInput.tsx: addif (controlsDisabled.value) returnguard toonBeforeinputVNumberInput.spec.browser.tsx: add regression test for typing non-digit chars while readonlyFixes #22677