From 75e14a66d43aeb073dd03ad67c9ee7dd2ec84128 Mon Sep 17 00:00:00 2001 From: mertsincan Date: Mon, 6 Sep 2021 14:01:55 +0300 Subject: [PATCH] Fixed #1502 - Add allowEmpty property to InputNumber --- src/components/inputnumber/InputNumber.d.ts | 1 + src/components/inputnumber/InputNumber.vue | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/inputnumber/InputNumber.d.ts b/src/components/inputnumber/InputNumber.d.ts index 86ec19269..83d21a342 100755 --- a/src/components/inputnumber/InputNumber.d.ts +++ b/src/components/inputnumber/InputNumber.d.ts @@ -20,6 +20,7 @@ interface InputNumberProps { min?: number; max?: number; step?: number; + allowEmpty?: boolean; inputStyle?: any; inputClass?: string; style?: any; diff --git a/src/components/inputnumber/InputNumber.vue b/src/components/inputnumber/InputNumber.vue index 700c994fb..792763568 100755 --- a/src/components/inputnumber/InputNumber.vue +++ b/src/components/inputnumber/InputNumber.vue @@ -104,6 +104,10 @@ export default { type: Number, default: 1 }, + allowEmpty: { + type: Boolean, + default: true + }, style: null, class: null, inputStyle: null, @@ -740,6 +744,7 @@ export default { if (valueStr != null) { newValue = this.parseValue(valueStr); + newValue = !newValue && !this.allowEmpty ? 0 : newValue; this.updateInput(newValue, insertedValueStr, operation, valueStr); this.handleOnInput(event, currentValue, newValue); @@ -931,7 +936,8 @@ export default { } }, formattedValue() { - return this.formatValue(this.modelValue); + const val = !this.modelValue && !this.allowEmpty ? 0 : this.modelValue; + return this.formatValue(val); } }, components: {