Process UX feedback for DownloadDialog (#942)

This commit is contained in:
Jon Koops 2021-08-05 12:42:29 +02:00 committed by GitHub
parent be0506653d
commit 25376c75fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,7 +12,7 @@ import {
TextArea, TextArea,
} from "@patternfly/react-core"; } from "@patternfly/react-core";
import FileSaver from "file-saver"; import FileSaver from "file-saver";
import React, { useMemo, useState } from "react"; import React, { useEffect, useMemo, useState } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { useAdminClient, useFetch } from "../../context/auth/AdminClient"; import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
import { useServerInfo } from "../../context/server-info/ServerInfoProvider"; import { useServerInfo } from "../../context/server-info/ServerInfoProvider";
@ -65,6 +65,10 @@ export const DownloadDialog = ({
(snippet) => setSnippet(snippet), (snippet) => setSnippet(snippet),
[id, selected] [id, selected]
); );
// Clear snippet when selected config changes, this prevents old snippets from being displayed during fetch.
useEffect(() => setSnippet(""), [id, selected]);
return ( return (
<ConfirmDialogModal <ConfirmDialogModal
titleKey={t("clients:downloadAdaptorTitle")} titleKey={t("clients:downloadAdaptorTitle")}
@ -113,9 +117,7 @@ export const DownloadDialog = ({
<Select <Select
toggleId="type" toggleId="type"
isOpen={openType} isOpen={openType}
onToggle={() => { onToggle={(isExpanded) => setOpenType(isExpanded)}
setOpenType(!openType);
}}
variant={SelectVariant.single} variant={SelectVariant.single}
value={selected} value={selected}
selections={selected} selections={selected}