From 60b3806dab9df92af2bc44079b5d43621a2ff98c Mon Sep 17 00:00:00 2001 From: betavs Date: Fri, 17 Nov 2023 17:12:00 +0800 Subject: [PATCH 1/2] fix(input-number): when zero is entered, value displayed isn't expected --- components/lib/inputnumber/InputNumber.vue | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/components/lib/inputnumber/InputNumber.vue b/components/lib/inputnumber/InputNumber.vue index 0b3682953..21a1db15e 100755 --- a/components/lib/inputnumber/InputNumber.vue +++ b/components/lib/inputnumber/InputNumber.vue @@ -869,9 +869,15 @@ export default { selectionEnd = sRegex.lastIndex + tRegex.lastIndex; this.$refs.input.$el.setSelectionRange(selectionEnd, selectionEnd); } else if (newLength === currentLength) { - if (operation === 'insert' || operation === 'delete-back-single') this.$refs.input.$el.setSelectionRange(selectionEnd + 1, selectionEnd + 1); - else if (operation === 'delete-single') this.$refs.input.$el.setSelectionRange(selectionEnd - 1, selectionEnd - 1); - else if (operation === 'delete-range' || operation === 'spin') this.$refs.input.$el.setSelectionRange(selectionEnd, selectionEnd); + if (operation === 'insert' || operation === 'delete-back-single') { + const newSelectionEnd = selectionEnd + Number(this.isDecimalSign(value) || this.isDecimalSign(insertedValueStr)); + + this.$refs.input.$el.setSelectionRange(newSelectionEnd, newSelectionEnd); + } else if (operation === 'delete-single') { + this.$refs.input.$el.setSelectionRange(selectionEnd - 1, selectionEnd - 1); + } else if (operation === 'delete-range' || operation === 'spin') { + this.$refs.input.$el.setSelectionRange(selectionEnd, selectionEnd); + } } else if (operation === 'delete-back-single') { let prevChar = inputValue.charAt(selectionEnd - 1); let nextChar = inputValue.charAt(selectionEnd); From 44dd8cd329438307b0aec4215a8f6b0abf935dfe Mon Sep 17 00:00:00 2001 From: betavs Date: Wed, 17 Jan 2024 15:11:20 +0800 Subject: [PATCH 2/2] perf(input-number): when zero is entered, value displayed isn't expected --- components/lib/inputnumber/InputNumber.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/lib/inputnumber/InputNumber.vue b/components/lib/inputnumber/InputNumber.vue index 21a1db15e..4f4861e7d 100755 --- a/components/lib/inputnumber/InputNumber.vue +++ b/components/lib/inputnumber/InputNumber.vue @@ -870,7 +870,8 @@ export default { this.$refs.input.$el.setSelectionRange(selectionEnd, selectionEnd); } else if (newLength === currentLength) { if (operation === 'insert' || operation === 'delete-back-single') { - const newSelectionEnd = selectionEnd + Number(this.isDecimalSign(value) || this.isDecimalSign(insertedValueStr)); + const re = /[.,]/g; + const newSelectionEnd = selectionEnd + Number(re.test(value) || re.test(insertedValueStr)); this.$refs.input.$el.setSelectionRange(newSelectionEnd, newSelectionEnd); } else if (operation === 'delete-single') {