From 25376c75fd0d5199a3951de90f784447b7c437f5 Mon Sep 17 00:00:00 2001 From: Jon Koops Date: Thu, 5 Aug 2021 12:42:29 +0200 Subject: [PATCH] Process UX feedback for DownloadDialog (#942) --- src/components/download-dialog/DownloadDialog.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/download-dialog/DownloadDialog.tsx b/src/components/download-dialog/DownloadDialog.tsx index 2ac50c8069..2a4f8e53fd 100644 --- a/src/components/download-dialog/DownloadDialog.tsx +++ b/src/components/download-dialog/DownloadDialog.tsx @@ -12,7 +12,7 @@ import { TextArea, } from "@patternfly/react-core"; import FileSaver from "file-saver"; -import React, { useMemo, useState } from "react"; +import React, { useEffect, useMemo, useState } from "react"; import { useTranslation } from "react-i18next"; import { useAdminClient, useFetch } from "../../context/auth/AdminClient"; import { useServerInfo } from "../../context/server-info/ServerInfoProvider"; @@ -65,6 +65,10 @@ export const DownloadDialog = ({ (snippet) => setSnippet(snippet), [id, selected] ); + + // Clear snippet when selected config changes, this prevents old snippets from being displayed during fetch. + useEffect(() => setSnippet(""), [id, selected]); + return ( { - setOpenType(!openType); - }} + onToggle={(isExpanded) => setOpenType(isExpanded)} variant={SelectVariant.single} value={selected} selections={selected}