From ae482f522aec7ddd94aa767f90dd64a6aa0c7e4d Mon Sep 17 00:00:00 2001 From: feightwywx Date: Wed, 30 Jul 2025 23:02:07 +0800 Subject: [PATCH] fix(frontend/input/AffTextField): upload problem after clearing the same file fix(frontend/input/AffTextField): required error still shows after uploading file --- frontend/components/input.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/components/input.tsx b/frontend/components/input.tsx index 2349754..50d3c8a 100644 --- a/frontend/components/input.tsx +++ b/frontend/components/input.tsx @@ -80,6 +80,7 @@ interface ImageFieldProps { export const AffTextField: React.FC = ({ ...props }) => { const [field, meta, helpers] = useField(props as { name: any }); const { t } = useTranslation("tools"); + const inputRef = useRef(null); let isError = Boolean(meta.touched && meta.error); @@ -92,7 +93,7 @@ export const AffTextField: React.FC = ({ ...props }) => { reader.onload = (e: ProgressEvent) => { if (e.target?.result) { helpers.setValue(e.target.result as string); - helpers.setTouched(true); + inputRef.current!.value = ''; } }; reader.readAsText(file); @@ -116,6 +117,7 @@ export const AffTextField: React.FC = ({ ...props }) => { onChange={handleFileChange} style={{ display: "none" }} id="file-input" + ref={inputRef} />