Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions vue2-vuetify/src/controls/NumberControlRenderer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
v-bind="vuetifyProps('v-text-field', { type: 'number' })"
@input="onInputChange"
@focus="isFocused = true"
@blur="isFocused = false"
@blur="isFocused = false; onBlur()"
></v-text-field>
</v-hover>
</control-wrapper>
Expand Down Expand Up @@ -86,7 +86,7 @@ const controlRenderer = defineComponent({

const numberAsString = inputStringIsInExponentForm
? result.toExponential()
: result.toPrecision();
: result.toString();

const numberIsInExponentForm =
numberAsString.includes('E') || numberAsString.includes('e');
Expand All @@ -100,6 +100,9 @@ const controlRenderer = defineComponent({
}
this.onChange(result);
},
onBlur() : void {
this.inputValue = Number(this.inputValue).toString();
}
toNumberOrString(value: string): number | string {
// have a regex test before parseFloat to make sure that invalid input won't be ignored and will lead to errors, parseFloat will parse invalid input such 7.22m6 as 7.22
if (NUMBER_REGEX_TEST.test(value)) {
Expand Down