Skip to content

Commit ae482f5

Browse files
committed
fix(frontend/input/AffTextField): upload problem after clearing the same file
fix(frontend/input/AffTextField): required error still shows after uploading file
1 parent 4f8cb8e commit ae482f5

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

frontend/components/input.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ interface ImageFieldProps {
8080
export const AffTextField: React.FC<TextFieldProps> = ({ ...props }) => {
8181
const [field, meta, helpers] = useField(props as { name: any });
8282
const { t } = useTranslation("tools");
83+
const inputRef = useRef<HTMLInputElement>(null);
8384

8485
let isError = Boolean(meta.touched && meta.error);
8586

@@ -92,7 +93,7 @@ export const AffTextField: React.FC<TextFieldProps> = ({ ...props }) => {
9293
reader.onload = (e: ProgressEvent<FileReader>) => {
9394
if (e.target?.result) {
9495
helpers.setValue(e.target.result as string);
95-
helpers.setTouched(true);
96+
inputRef.current!.value = '';
9697
}
9798
};
9899
reader.readAsText(file);
@@ -116,6 +117,7 @@ export const AffTextField: React.FC<TextFieldProps> = ({ ...props }) => {
116117
onChange={handleFileChange}
117118
style={{ display: "none" }}
118119
id="file-input"
120+
ref={inputRef}
119121
/>
120122
<label htmlFor="file-input">
121123
<IconButton onClick={async () => {}} component="span">

0 commit comments

Comments
 (0)