From 664fa6671afc1258ea4f859c9fb64dcf796ba097 Mon Sep 17 00:00:00 2001 From: zxawry Date: Thu, 29 Aug 2019 16:51:31 +0100 Subject: [PATCH] fix blank tags when tags search field is empty --- src/ui/component/tagsSearch/view.jsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/ui/component/tagsSearch/view.jsx b/src/ui/component/tagsSearch/view.jsx index ee7801653..59eff2bc3 100644 --- a/src/ui/component/tagsSearch/view.jsx +++ b/src/ui/component/tagsSearch/view.jsx @@ -22,6 +22,8 @@ type Props = { export default function TagSelect(props: Props) { const { unfollowedTags = [], followedTags = [], doToggleTagFollow, doAddTag, onSelect, suggestMature } = props; const [newTag, setNewTag] = useState(''); + // Not old, just untouched + const [oldTag, setOldTag] = useState(''); let tags = unfollowedTags.slice(); if (newTag) { @@ -42,12 +44,18 @@ export default function TagSelect(props: Props) { const suggestedTransitions = useTransition(suggestedTags, tag => tag, unfollowedTagsAnimation); function onChange(e) { - setNewTag(e.target.value); + setNewTag(e.target.value.trim()); + setOldTag(e.target.value); } function handleSubmit(e) { e.preventDefault(); setNewTag(''); + setOldTag(''); + + if (newTag.length <= 0) { + return; + } if (onSelect) { onSelect({ name: newTag }); @@ -78,7 +86,7 @@ export default function TagSelect(props: Props) { onChange={onChange} placeholder={__('Search for more tags')} type="text" - value={newTag} + value={oldTag} />