Skip to content
Snippets Groups Projects
Unverified Commit 7e4004ba authored by kchadha's avatar kchadha Committed by GitHub
Browse files

Merge pull request #1750 from kchadha/load-button-fix

Fixes for load button issues.
parents 7ff76764 bb9f63ce
No related branches found
No related tags found
No related merge requests found
...@@ -24,18 +24,24 @@ class LoadButton extends React.Component { ...@@ -24,18 +24,24 @@ class LoadButton extends React.Component {
}; };
} }
handleChange (e) { handleChange (e) {
this.props.openLoadingState();
// Remove the hash if any (without triggering a hash change event or a reload) // Remove the hash if any (without triggering a hash change event or a reload)
history.replaceState({}, document.title, '.'); history.replaceState({}, document.title, '.');
const reader = new FileReader(); const reader = new FileReader();
const thisFileInput = e.target;
reader.onload = () => this.props.vm.loadProject(reader.result) reader.onload = () => this.props.vm.loadProject(reader.result)
.then(() => { .then(() => {
this.props.closeLoadingState(); this.props.closeLoadingState();
// Reset the file input after project is loaded
// This is necessary in case the user wants to reload a project
thisFileInput.value = null;
}) })
.catch(error => { .catch(error => {
this.setState({loadingError: true, errorMessage: error}); this.setState({loadingError: true, errorMessage: error});
}); });
reader.readAsArrayBuffer(e.target.files[0]); if (thisFileInput.files) { // Don't attempt to load if no file was selected
this.props.openLoadingState();
reader.readAsArrayBuffer(thisFileInput.files[0]);
}
} }
handleClick () { handleClick () {
this.fileInput.click(); this.fileInput.click();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment