diff --git a/apps/client/src/widgets/dialogs/import.tsx b/apps/client/src/widgets/dialogs/import.tsx
index a54a01573..c041511d4 100644
--- a/apps/client/src/widgets/dialogs/import.tsx
+++ b/apps/client/src/widgets/dialogs/import.tsx
@@ -37,7 +37,7 @@ export default function ImportDialog() {
onSubmit={async () => {
if (!files || !parentNoteId) {
return;
- }
+ }
const options: UploadFilesOptions = {
safeImport: boolToString(safeImport),
@@ -51,7 +51,10 @@ export default function ImportDialog() {
setShown(false);
await importService.uploadFiles("notes", parentNoteId, Array.from(files), options);
}}
- onHidden={() => setShown(false)}
+ onHidden={() => {
+ setShown(false);
+ setFiles(null);
+ }}
footer={}
show={shown}
>
@@ -82,7 +85,7 @@ export default function ImportDialog() {
currentValue={codeImportedAsCode} onChange={setCodeImportedAsCode}
/>
@@ -92,4 +95,4 @@ export default function ImportDialog() {
function boolToString(value: boolean) {
return value ? "true" : "false";
-}
\ No newline at end of file
+}
diff --git a/apps/client/src/widgets/dialogs/upload_attachments.tsx b/apps/client/src/widgets/dialogs/upload_attachments.tsx
index 2a780e616..7d3d54bda 100644
--- a/apps/client/src/widgets/dialogs/upload_attachments.tsx
+++ b/apps/client/src/widgets/dialogs/upload_attachments.tsx
@@ -40,14 +40,17 @@ export default function UploadAttachmentsDialog() {
if (!files || !parentNoteId) {
return;
}
-
+
setIsUploading(true);
const filesCopy = Array.from(files);
await importService.uploadFiles("attachments", parentNoteId, filesCopy, { shrinkImages });
setIsUploading(false);
setShown(false);
}}
- onHidden={() => setShown(false)}
+ onHidden={() => {
+ setShown(false);
+ setFiles(null);
+ }}
show={shown}
>
@@ -55,7 +58,7 @@ export default function UploadAttachmentsDialog() {
-
diff --git a/apps/client/src/widgets/react/FormFileUpload.tsx b/apps/client/src/widgets/react/FormFileUpload.tsx
index c43008b09..83db15ebb 100644
--- a/apps/client/src/widgets/react/FormFileUpload.tsx
+++ b/apps/client/src/widgets/react/FormFileUpload.tsx
@@ -1,6 +1,6 @@
import { Ref } from "preact";
import Button, { ButtonProps } from "./Button";
-import { useRef } from "preact/hooks";
+import { useEffect, useRef } from "preact/hooks";
interface FormFileUploadProps {
name?: string;
@@ -11,6 +11,11 @@ interface FormFileUploadProps {
}
export default function FormFileUpload({ inputRef, name, onChange, multiple, hidden }: FormFileUploadProps) {
+ // Prevent accidental reuse of a file selected in a previous instance of the upload form.
+ useEffect(() => {
+ onChange(null);
+ }, []);
+
return (
)
@@ -26,7 +31,7 @@ export default function FormFileUpload({ inputRef, name, onChange, multiple, hid
/**
* Combination of a button with a hidden file upload field.
- *
+ *
* @param param the change listener for the file upload and the properties for the button.
*/
export function FormFileUploadButton({ onChange, ...buttonProps }: Omit & Pick) {
@@ -39,10 +44,10 @@ export function FormFileUploadButton({ onChange, ...buttonProps }: Omit inputRef.current?.click()}
/>
>
)
-}
\ No newline at end of file
+}