From 3b04b3bbf8c12f389e5b3527c48e71f12d63962b Mon Sep 17 00:00:00 2001 From: knguyenrise8 <159168836+knguyenrise8@users.noreply.github.com> Date: Fri, 27 Dec 2024 13:23:41 -0600 Subject: [PATCH] fix(RV-428): Fix change upload flow to reflect UI (#494) --- frontend/package-lock.json | 19 ++++++++++--------- frontend/src/components/ExtractUploadFile.tsx | 10 ++++++++-- frontend/src/components/FileInput.tsx | 2 +- .../src/components/FileInput/file-input.tsx | 7 ++++--- .../src/components/FileInput/file-preview.tsx | 4 +++- frontend/src/components/UploadFile.scss | 2 +- frontend/src/components/UploadFile.tsx | 5 +++++ frontend/src/pages/AnnotateTemplate.tsx | 1 + .../UploadTemplate.test.tsx.snap | 1 + 9 files changed, 34 insertions(+), 17 deletions(-) diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 211f0131..ef16ebe5 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -2474,9 +2474,9 @@ "optional": true }, "node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", "dev": true, "license": "MIT", "dependencies": { @@ -4635,9 +4635,9 @@ } }, "node_modules/micromatch": { - "version": "4.0.7", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.7.tgz", - "integrity": "sha512-LPP/3KorzCwBxfeUuZmaR6bG2kdeHSbe0P2tY3FLRU4vYrjYz5hI4QZwV0njUx3jeuKe67YukQ1LSPZBKDqO/Q==", + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", "dev": true, "license": "MIT", "dependencies": { @@ -4785,9 +4785,9 @@ "optional": true }, "node_modules/nanoid": { - "version": "3.3.7", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", - "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", + "version": "3.3.8", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.8.tgz", + "integrity": "sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w==", "dev": true, "funding": [ { @@ -4795,6 +4795,7 @@ "url": "https://github.com/sponsors/ai" } ], + "license": "MIT", "bin": { "nanoid": "bin/nanoid.cjs" }, diff --git a/frontend/src/components/ExtractUploadFile.tsx b/frontend/src/components/ExtractUploadFile.tsx index 7084f614..3faa91a9 100644 --- a/frontend/src/components/ExtractUploadFile.tsx +++ b/frontend/src/components/ExtractUploadFile.tsx @@ -150,6 +150,11 @@ export const ExtractUploadFile: React.FC = ({ const handleChange = (event: ChangeEvent) => { if (event.target.files && event.target.files.length > 0) { const files = Array.from(event.target.files); + if (files.length > 0) { + setUploadedFile([]); + clearFiles(); + setHasError(false); + } setUploadedFile(files); const filesObj: IFilesObj = { files }; localStorage.setItem("files", JSON.stringify(filesObj)); @@ -243,8 +248,9 @@ export const ExtractUploadFile: React.FC = ({ > {uploadedFile.length} file(s) selected - {!isUploadComplete && ( = ({ chooseText="Change file(s)" dragText=" " /> - )}
= ({ style={{ width: "80%" }} > ) => void; onDrop?: (e: React.DragEvent) => void; }; @@ -43,6 +44,7 @@ export const FileInputForwardRef: React.ForwardRefRenderFunction< multiple, className, accept, + hidePreview, onChange, onDrop, ...inputProps @@ -103,15 +105,14 @@ export const FileInputForwardRef: React.ForwardRefRenderFunction< filePreviews.push( , ); } } - const instructionClasses = classnames("usa-file-input__instructions", { - "display-none": filePreviews.length > 0, }); const previewHeaderText = @@ -187,7 +188,7 @@ export const FileInputForwardRef: React.ForwardRefRenderFunction< onDragLeave={handleDragLeave} onDrop={handleDrop} > - {filePreviews.length > 0 && ( + {filePreviews.length > 0 && !hidePreview && (
{ const [previewSrc, setPreviewSrc] = useState(SPACER_GIF); const [showGenericPreview, setShowGenericPreview] = useState(false); @@ -47,7 +49,7 @@ export const FilePreview = ({ return (