diff --git a/vue2-vuetify/src/controls/NumberControlRenderer.vue b/vue2-vuetify/src/controls/NumberControlRenderer.vue index 549dc2e4..8aed3b4e 100644 --- a/vue2-vuetify/src/controls/NumberControlRenderer.vue +++ b/vue2-vuetify/src/controls/NumberControlRenderer.vue @@ -24,7 +24,7 @@ v-bind="vuetifyProps('v-text-field', { type: 'number' })" @input="onInputChange" @focus="isFocused = true" - @blur="isFocused = false" + @blur="isFocused = false; onBlur()" > @@ -86,7 +86,7 @@ const controlRenderer = defineComponent({ const numberAsString = inputStringIsInExponentForm ? result.toExponential() - : result.toPrecision(); + : result.toString(); const numberIsInExponentForm = numberAsString.includes('E') || numberAsString.includes('e'); @@ -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)) {