File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed
Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -272,6 +272,18 @@ export class FormFileInput extends React.Component {
272272 this . inputRef . current . click ( ) ;
273273 }
274274
275+ clearFile = ( ) => {
276+ let event = {
277+ target : {
278+ type : 'text' ,
279+ value : '' ,
280+ name : this . props . name
281+ }
282+ } ;
283+
284+ this . props . onChange ( event ) ;
285+ }
286+
275287 render ( ) {
276288 let { label, value, ...props } = { value, ...this . props } ;
277289 props . type = 'file' ;
@@ -280,13 +292,15 @@ export class FormFileInput extends React.Component {
280292 if ( props . readOnly )
281293 props . disabled = true ;
282294
283-
284295 return (
285- < div >
296+ < div >
286297 { label && < label > { label } </ label > }
287298 < div className = "rjf-file-field" >
288299 { this . state . value &&
289- < div className = "rjf-current-file-name" > Current file: < span > { this . state . fileName } </ span > </ div >
300+ < div className = "rjf-current-file-name" >
301+ Current file: < span > { this . state . fileName } </ span > { ' ' }
302+ < Button className = "remove-file" onClick = { this . clearFile } > Clear</ Button >
303+ </ div >
290304 }
291305 { this . state . value && ! this . state . loading && 'Change:' }
292306 { this . state . loading ?
You can’t perform that action at this time.
0 commit comments