diff --git a/src/containers/load-button.jsx b/src/containers/load-button.jsx index e52a6735da91bb32005c531ddd35e267ea58e541..9364728a4d9702ca3ffdfbe5f156b693f34da7e9 100644 --- a/src/containers/load-button.jsx +++ b/src/containers/load-button.jsx @@ -24,18 +24,24 @@ class LoadButton extends React.Component { }; } handleChange (e) { - this.props.openLoadingState(); // Remove the hash if any (without triggering a hash change event or a reload) history.replaceState({}, document.title, '.'); const reader = new FileReader(); + const thisFileInput = e.target; reader.onload = () => this.props.vm.loadProject(reader.result) .then(() => { 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 => { 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 () { this.fileInput.click();