Merge pull request #6845 from Abassion/master

Fix #6837 - Updated onInputKeyDown() on InputNumber so that it works as expected
pull/6860/head
Tuğçe Küçükoğlu 2024-11-25 16:16:28 +03:00 committed by GitHub
commit a2348d9351
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 2 deletions

View File

@ -385,6 +385,7 @@ export default {
let selectionStart = event.target.selectionStart;
let selectionEnd = event.target.selectionEnd;
let selectionRange = selectionEnd - selectionStart;
let inputValue = event.target.value;
let newValueStr = null;
const code = event.code || event.key;
@ -401,14 +402,20 @@ export default {
break;
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();
}
break;
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();
}