File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -80,6 +80,7 @@ interface ImageFieldProps {
8080export 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" >
You can’t perform that action at this time.
0 commit comments