fix(select): closes menu when enter key is pressed in filterable mode without options data

This commit is contained in:
07akioni 2021-09-11 19:54:09 +08:00
parent 1864eb5e61
commit c13b27bb20
3 changed files with 6 additions and 5 deletions

View File

@ -14,6 +14,7 @@
### Fixes
- Fix `n-p` warns when `depth` is number.
- Fix `n-select` closes menu when enter key is pressed in filterable mode without options data.
## 2.18.1 (2021-09-08)

View File

@ -14,6 +14,7 @@
### Fixes
- 修复 `n-p` `depth` 传入 number 报错
- 修复 `n-select` 在 filterable 并且菜单无数据是按下 enter 导致菜单关闭
## 2.18.1 (2021-09-08)

View File

@ -582,11 +582,10 @@ export default defineComponent({
case 'Enter':
case 'NumpadEnter':
if (mergedShowRef.value) {
const menu = menuRef.value
const pendingOptionData = menu?.getPendingTmNode()
if (pendingOptionData) {
handleToggleByTmNode(pendingOptionData)
} else {
const pendingTmNode = menuRef.value?.getPendingTmNode()
if (pendingTmNode) {
handleToggleByTmNode(pendingTmNode)
} else if (!props.filterable) {
closeMenu()
focusSelection()
}