fixes bug with UploadMediaForm

This commit is contained in:
James
2019-03-23 19:19:30 -04:00
parent 514dbed271
commit 2e742189c8

View File

@@ -129,6 +129,21 @@ class UploadMediaForm extends Component {
}
}
componentDidMount() {
this.inputRef.current.addEventListener('change', e => {
this.props.setSelectingFile(false);
// If there are files, submit the form
if (this.inputRef.current.files[0]) {
this.handleSubmit();
}
}, false);
}
componentWillUnmount() {
this.inputRef.current.removeEventListener('change');
}
handleSubmit = () => {
const data = new FormData(this.formRef.current);
api.requests.post(`${this.props.config.serverUrl}/upload`, data).then(