Chips: update arrow key spport
parent
a9bfa95f4b
commit
28bff76db8
|
@ -70,9 +70,11 @@ export default {
|
||||||
},
|
},
|
||||||
onInput(event) {
|
onInput(event) {
|
||||||
this.inputValue = event.target.value;
|
this.inputValue = event.target.value;
|
||||||
|
this.focusedIndex = null;
|
||||||
},
|
},
|
||||||
onFocus(event) {
|
onFocus(event) {
|
||||||
this.focused = true;
|
this.focused = true;
|
||||||
|
this.focusedIndex = null;
|
||||||
this.$emit('focus', event);
|
this.$emit('focus', event);
|
||||||
},
|
},
|
||||||
onBlur(event) {
|
onBlur(event) {
|
||||||
|
@ -105,15 +107,15 @@ export default {
|
||||||
|
|
||||||
case 'ArrowLeft':
|
case 'ArrowLeft':
|
||||||
if (inputValue.length === 0 && this.modelValue && this.modelValue.length > 0) {
|
if (inputValue.length === 0 && this.modelValue && this.modelValue.length > 0) {
|
||||||
if (this.focusedIndex === 0 || this.focusedIndex === null) this.focusedIndex = this.modelValue.length-1;
|
this.focusedIndex = this.focusedIndex === null ? this.modelValue.length -1 : this.focusedIndex - 1;
|
||||||
else this.focusedIndex--;
|
if (this.focusedIndex < 0) this.focusedIndex = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'ArrowRight':
|
case 'ArrowRight':
|
||||||
if (inputValue.length === 0 && this.modelValue && this.modelValue.length > 0) {
|
if (inputValue.length === 0 && this.modelValue && this.modelValue.length > 0) {
|
||||||
if (this.focusedIndex === null || this.focusedIndex === this.modelValue.length-1) this.focusedIndex = 0;
|
this.focusedIndex = this.focusedIndex === null ? 0 : this.focusedIndex + 1;
|
||||||
else this.focusedIndex++;
|
if (this.focusedIndex === this.modelValue.length) this.focusedIndex = this.modelValue.length - 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue