fix(select): options display fix when allow-create, also empty & entered #2826 #2854 (#2830)

* fix(select):created option showed incorrectly#2826

fix https://github.com/element-plus/element-plus/issues/2826

* fix(select): options display fix when allow-create, also empty & entered

fix #2826 #2854

Co-authored-by: hanx316 <xuanxinhan@vip.qq.com>
This commit is contained in:
Kisama
2021-08-08 16:11:39 +08:00
committed by GitHub
parent cdc6a6ac61
commit 08c41150ab

View File

@@ -81,16 +81,10 @@ export function useOption(props, states) {
}
const queryChange = (query: string) => {
// not in filtering, just show original options only
if (!query) {
states.visible = !props.created
} else {
// in filtering, do filter by RegExp
const regexp = new RegExp(escapeRegexpString(query), 'i')
states.visible = regexp.test(currentLabel.value)
if (!states.visible && !props.created) {
select.filteredOptionsCount--
}
const regexp = new RegExp(escapeRegexpString(query), 'i')
states.visible = regexp.test(currentLabel.value) || props.created
if (!states.visible) {
select.filteredOptionsCount--
}
}