Chips: update arrow key spport

pull/2835/head
Tuğçe Küçükoğlu 2022-08-05 16:03:08 +03:00
parent a9bfa95f4b
commit 28bff76db8
1 changed files with 6 additions and 4 deletions

View File

@ -70,9 +70,11 @@ export default {
},
onInput(event) {
this.inputValue = event.target.value;
this.focusedIndex = null;
},
onFocus(event) {
this.focused = true;
this.focusedIndex = null;
this.$emit('focus', event);
},
onBlur(event) {
@ -105,15 +107,15 @@ export default {
case 'ArrowLeft':
if (inputValue.length === 0 && this.modelValue && this.modelValue.length > 0) {
if (this.focusedIndex === 0 || this.focusedIndex === null) this.focusedIndex = this.modelValue.length-1;
else this.focusedIndex--;
this.focusedIndex = this.focusedIndex === null ? this.modelValue.length -1 : this.focusedIndex - 1;
if (this.focusedIndex < 0) this.focusedIndex = 0;
}
break;
case 'ArrowRight':
if (inputValue.length === 0 && this.modelValue && this.modelValue.length > 0) {
if (this.focusedIndex === null || this.focusedIndex === this.modelValue.length-1) this.focusedIndex = 0;
else this.focusedIndex++;
this.focusedIndex = this.focusedIndex === null ? 0 : this.focusedIndex + 1;
if (this.focusedIndex === this.modelValue.length) this.focusedIndex = this.modelValue.length - 1;
}
break;