From 34f4c072ddb19c97f19e95faf20d207c7ce1eccc Mon Sep 17 00:00:00 2001 From: shuai Date: Fri, 18 Nov 2022 10:36:46 +0800 Subject: [PATCH] fix: only write or edit content show required tag text --- i18n/en_US.yaml | 1 + ui/src/components/TagSelector/index.tsx | 20 ++++++++++++-------- ui/src/pages/Questions/Ask/index.tsx | 1 + 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/i18n/en_US.yaml b/i18n/en_US.yaml index 50734d4c..faa0cf7a 100644 --- a/i18n/en_US.yaml +++ b/i18n/en_US.yaml @@ -507,6 +507,7 @@ ui: search_tag: Search tag hint: "Describe what your question is about, at least one tag is required." no_result: No tags matched + tag_required_text: Required tag (at least one) header: nav: question: Questions diff --git a/ui/src/components/TagSelector/index.tsx b/ui/src/components/TagSelector/index.tsx index ab028dac..3597a6a7 100644 --- a/ui/src/components/TagSelector/index.tsx +++ b/ui/src/components/TagSelector/index.tsx @@ -19,6 +19,7 @@ interface IProps { onBlur?: () => void; hiddenDescription?: boolean; hiddenCreateBtn?: boolean; + showRequiredTagText?: boolean; alwaysShowAddBtn?: boolean; } @@ -32,6 +33,7 @@ const TagSelector: FC = ({ hiddenDescription = false, hiddenCreateBtn = false, alwaysShowAddBtn = false, + showRequiredTagText = false, }) => { const [initialValue, setInitialValue] = useState([...value]); const [currentIndex, setCurrentIndex] = useState(0); @@ -224,14 +226,16 @@ const TagSelector: FC = ({ )} - {tags && tags.filter((v) => v.recommend)?.length > 0 && ( - - Required tag (at least one) - - )} + {showRequiredTagText && + tags && + tags.filter((v) => v.recommend)?.length > 0 && ( + + {t('tag_required_text')} + + )} {tags?.map((item, index) => { return ( diff --git a/ui/src/pages/Questions/Ask/index.tsx b/ui/src/pages/Questions/Ask/index.tsx index 7b5053f3..79614a49 100644 --- a/ui/src/pages/Questions/Ask/index.tsx +++ b/ui/src/pages/Questions/Ask/index.tsx @@ -348,6 +348,7 @@ const Ask = () => { {formData.tags.errorMsg}