From bafa9991954ac8d6fefe5323d798bb17135dead5 Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Tue, 26 Jul 2022 16:23:23 +0700 Subject: [PATCH] fixed empty tag commit --- src/containers/tags/TagInput/index.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/containers/tags/TagInput/index.tsx b/src/containers/tags/TagInput/index.tsx index 30e20715..c5042f86 100644 --- a/src/containers/tags/TagInput/index.tsx +++ b/src/containers/tags/TagInput/index.tsx @@ -14,7 +14,7 @@ const prepareInput = (input: string): string[] => { .map((title: string) => title .trim() - .substr(0, 32) + .substring(0, 64) .toLowerCase() ) .filter(el => el.length > 0); @@ -42,6 +42,7 @@ const TagInput: FC = ({ exclude, onAppend, onClearTag, onSubmit }) => { } const items = prepareInput(value); + console.log(items); if (items.length > 1) { onAppend(items.slice(0, items.length - 1)); @@ -69,6 +70,7 @@ const TagInput: FC = ({ exclude, onAppend, onClearTag, onSubmit }) => { const created = prepareInput(input); if (created.length) { + console.log('appending?!!') onAppend(created); } @@ -104,6 +106,11 @@ const TagInput: FC = ({ exclude, onAppend, onClearTag, onSubmit }) => { const onAutocompleteSelect = useCallback( (val: string) => { setInput(''); + + if (!val.trim()) { + return; + } + onAppend([val]); }, [onAppend, setInput]