From 65c3c0cf92aec8babeafdd6c9b250096a797b0bd Mon Sep 17 00:00:00 2001 From: beichen <826237710@qq.com> Date: Thu, 11 Mar 2021 18:18:51 +0800 Subject: [PATCH] fix: click the Enter button and an empty tag may appear --- src/generate.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/generate.tsx b/src/generate.tsx index e91716200..bb7181731 100644 --- a/src/generate.tsx +++ b/src/generate.tsx @@ -722,6 +722,10 @@ export default function generateSelector< // If menu is open, OptionList will take charge // If mode isn't tags, press enter is not meaningful when you can't see any option const onSearchSubmit = (searchText: string) => { + // prevent empty tags from appearing when you click the Enter button + if (!searchText || !searchText.trim()) { + return; + } const newRawValues = Array.from( new Set([...mergedRawValue, searchText]), );