From 3ab8ce06f75e717bbb0c0610b1be72eabbce8642 Mon Sep 17 00:00:00 2001 From: mertsincan Date: Tue, 7 Sep 2021 17:17:07 +0300 Subject: [PATCH] Fixed #1513 - Input number caret issue with negatives --- src/components/inputnumber/InputNumber.vue | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/inputnumber/InputNumber.vue b/src/components/inputnumber/InputNumber.vue index 84f2f14e1..bb40936f1 100755 --- a/src/components/inputnumber/InputNumber.vue +++ b/src/components/inputnumber/InputNumber.vue @@ -851,6 +851,9 @@ export default { this._group.lastIndex = 0; this.$refs.input.$el.setSelectionRange(selectionEnd, selectionEnd); } + else if (inputValue === '-' && operation === 'insert') { + this.$refs.input.$el.setSelectionRange(selectionEnd + 1, selectionEnd + 1); + } else { selectionEnd = selectionEnd + (newLength - currentLength); this.$refs.input.$el.setSelectionRange(selectionEnd, selectionEnd); @@ -864,7 +867,7 @@ export default { let decimalCharIndex = val2.search(this._decimal); this._decimal.lastIndex = 0; - return val1.split(this._decimal)[0] + (decimalCharIndex !== -1 ? val2.slice(decimalCharIndex) : ''); + return decimalCharIndex !== -1 ? (val1.split(this._decimal)[0] + val2.slice(decimalCharIndex)) : val1; } return val1;