Merge pull request #5116 from RookieZoe/2.select
[select] fix script error when searching in select component
This commit is contained in:
commit
8857d163b3
1 changed files with 9 additions and 3 deletions
|
@ -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];
|
||||||
const option = this.getOptionData(optionComponent.componentOptions.propsData.value);
|
|
||||||
this.onOptionClick(option);
|
// fix a script error when searching
|
||||||
|
if (optionComponent) {
|
||||||
|
const option = this.getOptionData(optionComponent.componentOptions.propsData.value);
|
||||||
|
this.onOptionClick(option);
|
||||||
|
} else {
|
||||||
|
this.hideMenu();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const keysThatCanOpenSelect = ['ArrowUp', 'ArrowDown'];
|
const keysThatCanOpenSelect = ['ArrowUp', 'ArrowDown'];
|
||||||
|
@ -765,7 +771,7 @@
|
||||||
if (this.slotOptions && this.slotOptions.length === 0){
|
if (this.slotOptions && this.slotOptions.length === 0){
|
||||||
this.query = '';
|
this.query = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// 当 dropdown 一开始在控件下部显示,而滚动页面后变成在上部显示,如果选项列表的长度由内部动态变更了(搜索情况)
|
// 当 dropdown 一开始在控件下部显示,而滚动页面后变成在上部显示,如果选项列表的长度由内部动态变更了(搜索情况)
|
||||||
// dropdown 的位置不会重新计算,需要重新计算
|
// dropdown 的位置不会重新计算,需要重新计算
|
||||||
this.broadcast('Drop', 'on-update-popper');
|
this.broadcast('Drop', 'on-update-popper');
|
||||||
|
|
Loading…
Add table
Reference in a new issue