Skip to content

Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.

[Bug] Fix browse for file upload (#486)

Giuseppe Macrìea1392645c4e
diff --git a/src/components/common/file-uploader/file-upload.js b/src/components/common/file-uploader/file-upload.js
index 5f97df626..e57b62e22 100644
--- a/src/components/common/file-uploader/file-upload.js
+++ b/src/components/common/file-uploader/file-upload.js
@@ -148,17 +148,11 @@ export default class FileUpload extends Component {
return Boolean(fileExt);
};
- _handleFileDrop = (files, e) => {
+ _handleFileInput = (files, e) => {
if (e) {
e.stopPropagation();
}
- // After upgrading to react 16 this function is being called twice with different types: DragEvent and react class event
- // TODO: react-file-drop hasn't been updated and may not fully support react 16
- if (!(e instanceof Event)) {
- return;
- }
-
const nextState = {files: [], errorFiles: [], dragOver: false};
for (let i = 0; i < files.length; i++) {
const file = files[i];
@@ -226,7 +220,7 @@ export default class FileUpload extends Component {
targetAlwaysVisible
onDragOver={() => this._toggleDragState(true)}
onDragLeave={() => this._toggleDragState(false)}
- onDrop={this._handleFileDrop}
+ onDrop={this._handleFileInput}
>
<div className="file-upload__message">{CONFIG_UPLOAD_MESSAGE}</div>
<StyledFileDrop dragOver={dragOver}>
@@ -244,7 +238,7 @@ export default class FileUpload extends Component {
{!files.length ? <div>
<MsgWrapper>{MESSAGE}</MsgWrapper>
<span className="file-upload-or">or</span>
- <UploadButton onUpload={this._handleFileDrop}>
+ <UploadButton onUpload={this._handleFileInput}>
browse your files
</UploadButton>
</div> : null}