From ab5c187683ab4a0ca59336200340b6ab99c35bb0 Mon Sep 17 00:00:00 2001 From: Kevin Nguyen Date: Mon, 23 Dec 2024 10:36:28 -0600 Subject: [PATCH] fix(RV-428): Fix change upload flow to reflect UI --- frontend/package-lock.json | 19 ++++++++++--------- frontend/src/components/ExtractUploadFile.tsx | 8 ++++++-- 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 | 4 ++++ frontend/src/pages/AnnotateTemplate.tsx | 1 + 8 files changed, 30 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..5a3e824e 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,8 @@ export const ExtractUploadFile: React.FC = ({ > {uploadedFile.length} file(s) selected - {!isUploadComplete && ( = ({ chooseText="Change file(s)" dragText=" " /> - )}
) => 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 (