From 69e1c73db13d8dec43ea683d50e9e10e4afeff99 Mon Sep 17 00:00:00 2001 From: andreas-unleash Date: Fri, 9 Jun 2023 09:59:27 +0300 Subject: [PATCH] fix: only show simple tag type if there are no tag types in the server (#3919) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes `simple` tag type still visible in dropdown even after deleted ## About the changes Closes # [1-997](https://linear.app/unleash/issue/1-997/simple-tag-type-still-visible-in-dropdown-after-deletion) ### Important files ## Discussion points Signed-off-by: andreas-unleash --- .../ManageTagsDialog/ManageTagsDialog.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/frontend/src/component/feature/FeatureView/FeatureOverview/ManageTagsDialog/ManageTagsDialog.tsx b/frontend/src/component/feature/FeatureView/FeatureOverview/ManageTagsDialog/ManageTagsDialog.tsx index feb5cbc012..0f2b040814 100644 --- a/frontend/src/component/feature/FeatureView/FeatureOverview/ManageTagsDialog/ManageTagsDialog.tsx +++ b/frontend/src/component/feature/FeatureView/FeatureOverview/ManageTagsDialog/ManageTagsDialog.tsx @@ -51,11 +51,15 @@ export const ManageTagsDialog = ({ open, setOpen }: IManageTagsProps) => { const { updateFeatureTags, loading: featureLoading } = useFeatureApi(); const { tags, refetch, loading: tagsLoading } = useFeatureTags(featureId); const { setToastData } = useToast(); - const [tagType, setTagType] = useState({ - name: 'simple', - description: 'Simple tag to get you started', - icon: '', - }); + const initialTagType = + tagTypes && tagTypes.length > 0 + ? tagTypes[0] + : { + name: 'simple', + description: 'Simple tag to get you started', + icon: '', + }; + const [tagType, setTagType] = useState(initialTagType); const loading = featureLoading || tagsLoading;