fix a script error when searching

This commit is contained in:
Rookie_Zoe 2018-12-28 19:47:19 +08:00
parent 07201151da
commit c87d7efbd6

View file

@ -560,8 +560,14 @@
if (e.key === 'Enter') { if (e.key === 'Enter') {
if (this.focusIndex === -1) return this.hideMenu(); if (this.focusIndex === -1) return this.hideMenu();
const optionComponent = this.flatOptions[this.focusIndex]; const optionComponent = this.flatOptions[this.focusIndex];
// fix a script error when searching
if (optionComponent) {
const option = this.getOptionData(optionComponent.componentOptions.propsData.value); const option = this.getOptionData(optionComponent.componentOptions.propsData.value);
this.onOptionClick(option); this.onOptionClick(option);
} else {
this.hideMenu();
}
} }
} else { } else {
const keysThatCanOpenSelect = ['ArrowUp', 'ArrowDown']; const keysThatCanOpenSelect = ['ArrowUp', 'ArrowDown'];