From 8115f0b850755b08e4d846ddd8586823d790acca Mon Sep 17 00:00:00 2001 From: Sergio Crisostomo Date: Wed, 11 Oct 2017 11:34:48 +0200 Subject: [PATCH] fix regex and make empty string go back to old value on change --- src/components/input-number/input-number.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/input-number/input-number.vue b/src/components/input-number/input-number.vue index 638134cb..5f3b0349 100644 --- a/src/components/input-number/input-number.vue +++ b/src/components/input-number/input-number.vue @@ -254,13 +254,13 @@ change (event) { let val = event.target.value.trim(); - if (event.type == 'input' && val.match(/^\.$|\.$/)) return; // prevent fire early if decimal. If no more input the change event will fire later + if (event.type == 'input' && val.match(/^\-?\.?$|\.$/)) return; // prevent fire early if decimal. If no more input the change event will fire later if (event.type == 'change' && Number(val) === this.currentValue) return; // already fired change for input event const {min, max} = this; - + const isEmptyString = val.length === 0; val = Number(val); - if (!isNaN(val)) { + if (!isNaN(val) && !isEmptyString) { this.currentValue = val; if (val > max) {