Updated onInputKeyDown() on InputNumber.vue. so that it works as expected when the input value is selected.
parent
bd7161298a
commit
146af0f69e
|
@ -385,6 +385,7 @@ export default {
|
||||||
|
|
||||||
let selectionStart = event.target.selectionStart;
|
let selectionStart = event.target.selectionStart;
|
||||||
let selectionEnd = event.target.selectionEnd;
|
let selectionEnd = event.target.selectionEnd;
|
||||||
|
let selectionRange = selectionEnd - selectionStart;
|
||||||
let inputValue = event.target.value;
|
let inputValue = event.target.value;
|
||||||
let newValueStr = null;
|
let newValueStr = null;
|
||||||
const code = event.code || event.key;
|
const code = event.code || event.key;
|
||||||
|
@ -401,14 +402,20 @@ export default {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'ArrowLeft':
|
case 'ArrowLeft':
|
||||||
if (!this.isNumeralChar(inputValue.charAt(selectionStart - 1))) {
|
if (selectionRange > 1) {
|
||||||
|
const cursorPosition = this.isNumeralChar(inputValue.charAt(selectionStart)) ? selectionStart + 1 : selectionStart + 2;
|
||||||
|
this.$refs.input.$el.setSelectionRange(cursorPosition, cursorPosition);
|
||||||
|
} else if (!this.isNumeralChar(inputValue.charAt(selectionStart - 1))) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'ArrowRight':
|
case 'ArrowRight':
|
||||||
if (!this.isNumeralChar(inputValue.charAt(selectionStart))) {
|
if (selectionRange > 1) {
|
||||||
|
const cursorPosition = selectionEnd - 1;
|
||||||
|
this.$refs.input.$el.setSelectionRange(cursorPosition, cursorPosition);
|
||||||
|
} else if (!this.isNumeralChar(inputValue.charAt(selectionStart))) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue