Commit c87d7efbd6af5c458b262e2bd41aa687be714b0b
1 parent
07201151
fix a script error when searching
Showing
1 changed file
with
9 additions
and
3 deletions
Show diff stats
src/components/select/select.vue
@@ -560,8 +560,14 @@ | @@ -560,8 +560,14 @@ | ||
560 | if (e.key === 'Enter') { | 560 | if (e.key === 'Enter') { |
561 | if (this.focusIndex === -1) return this.hideMenu(); | 561 | if (this.focusIndex === -1) return this.hideMenu(); |
562 | const optionComponent = this.flatOptions[this.focusIndex]; | 562 | const optionComponent = this.flatOptions[this.focusIndex]; |
563 | - const option = this.getOptionData(optionComponent.componentOptions.propsData.value); | ||
564 | - this.onOptionClick(option); | 563 | + |
564 | + // fix a script error when searching | ||
565 | + if (optionComponent) { | ||
566 | + const option = this.getOptionData(optionComponent.componentOptions.propsData.value); | ||
567 | + this.onOptionClick(option); | ||
568 | + } else { | ||
569 | + this.hideMenu(); | ||
570 | + } | ||
565 | } | 571 | } |
566 | } else { | 572 | } else { |
567 | const keysThatCanOpenSelect = ['ArrowUp', 'ArrowDown']; | 573 | const keysThatCanOpenSelect = ['ArrowUp', 'ArrowDown']; |
@@ -751,7 +757,7 @@ | @@ -751,7 +757,7 @@ | ||
751 | if (this.slotOptions && this.slotOptions.length === 0){ | 757 | if (this.slotOptions && this.slotOptions.length === 0){ |
752 | this.query = ''; | 758 | this.query = ''; |
753 | } | 759 | } |
754 | - | 760 | + |
755 | // 当 dropdown 一开始在控件下部显示,而滚动页面后变成在上部显示,如果选项列表的长度由内部动态变更了(搜索情况) | 761 | // 当 dropdown 一开始在控件下部显示,而滚动页面后变成在上部显示,如果选项列表的长度由内部动态变更了(搜索情况) |
756 | // dropdown 的位置不会重新计算,需要重新计算 | 762 | // dropdown 的位置不会重新计算,需要重新计算 |
757 | this.broadcast('Drop', 'on-update-popper'); | 763 | this.broadcast('Drop', 'on-update-popper'); |