From 08c41150abfa9d330352b049a8b2e5e1ee3a4a9a Mon Sep 17 00:00:00 2001 From: Kisama <62412453+noah19846@users.noreply.github.com> Date: Sun, 8 Aug 2021 16:11:39 +0800 Subject: [PATCH] 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 --- packages/select/src/useOption.ts | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/packages/select/src/useOption.ts b/packages/select/src/useOption.ts index a2377bf3ad..11ce6e5565 100644 --- a/packages/select/src/useOption.ts +++ b/packages/select/src/useOption.ts @@ -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-- } }