Skip to content

Commit

Permalink
Fixed #1510 - inputnumber : both prefix and currency Input error
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Sep 7, 2021
1 parent f761200 commit dc8b421
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/components/inputnumber/InputNumber.vue
Original file line number Diff line number Diff line change
Expand Up @@ -682,17 +682,22 @@ export default {
let valueLength = inputValue.length;
let index = null;
// remove prefix
let prefixLength = (this.prefixChar || '').length;
inputValue = inputValue.replace(this._prefix, '');
selectionStart = selectionStart - prefixLength;
let char = inputValue.charAt(selectionStart);
if (this.isNumeralChar(char)) {
return;
return selectionStart + prefixLength;
}
//left
let i = selectionStart - 1;
while (i >= 0) {
char = inputValue.charAt(i);
if (this.isNumeralChar(char)) {
index = i;
index = i + prefixLength;
break;
}
else {
Expand All @@ -704,11 +709,11 @@ export default {
this.$refs.input.$el.setSelectionRange(index + 1, index + 1);
}
else {
i = selectionStart + 1;
i = selectionStart;
while (i < valueLength) {
char = inputValue.charAt(i);
if (this.isNumeralChar(char)) {
index = i;
index = i + prefixLength;
break;
}
else {
Expand All @@ -720,6 +725,8 @@ export default {
this.$refs.input.$el.setSelectionRange(index, index);
}
}
return index || 0;
},
onInputClick() {
this.initCursor();
Expand Down Expand Up @@ -796,9 +803,8 @@ export default {
if (currentLength === 0) {
this.$refs.input.$el.value = newValue;
this.$refs.input.$el.setSelectionRange(0, 0);
this.initCursor();
const prefixLength = (this.prefixChar || '').length;
const selectionEnd = prefixLength + insertedValueStr.length;
const index = this.initCursor();
const selectionEnd = index + insertedValueStr.length;
this.$refs.input.$el.setSelectionRange(selectionEnd, selectionEnd);
}
else {
Expand Down

0 comments on commit dc8b421

Please sign in to comment.