fix(client/import): file remains from previous instance (closes #7428)

This commit is contained in:
Elian Doran 2025-10-20 20:24:43 +03:00
parent 00720ae58f
commit 8fc7a20220
No known key found for this signature in database
3 changed files with 23 additions and 12 deletions

View File

@ -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={<Button text={t("import.import")} primary disabled={!files} />}
show={shown}
>

View File

@ -47,7 +47,10 @@ export default function UploadAttachmentsDialog() {
setIsUploading(false);
setShown(false);
}}
onHidden={() => setShown(false)}
onHidden={() => {
setShown(false);
setFiles(null);
}}
show={shown}
>
<FormGroup name="files" label={t("upload_attachments.choose_files")} description={description}>

View File

@ -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 (
<label class="tn-file-input tn-input-field" style={hidden ? { display: "none" } : undefined}>
<input