React-dropzone: 4.2.7 isFileDialogActive timeout issue

Created on 22 Jan 2018  路  4Comments  路  Source: react-dropzone/react-dropzone

Heya all.

  • [x] I found a bug
  • [ ] I want to propose a feature

What is the current behavior?
as of 4.2.7 I am getting a null issue in the onFileDialogCancel timeout.

In the below snippet, _this4.fileInputEl is null, and so .files fails on it. 4.2.6 works great.I've tested the lastest versions of Chrome, and even IE11

 key: 'onFileDialogCancel',
    value: function onFileDialogCancel() {
      var _this4 = this;

      // timeout will not recognize context of this method
      var onFileDialogCancel = this.props.onFileDialogCancel;
      // execute the timeout only if the FileDialog is opened in the browser

      if (this.isFileDialogActive) {
        setTimeout(function () {
          // Returns an object as FileList
          var files = _this4.fileInputEl.files;


          if (!files.length) {
            _this4.isFileDialogActive = false;
          }

          if (typeof onFileDialogCancel === 'function') {
            onFileDialogCancel();
          }
        }, 300);
      }
    }

If the current behavior is a bug, please provide the steps to reproduce.

I'm selecting a file from the browser file popup, which replaces the dropzone component with an image preview. The error occurs when the preview appears, only in 4.2.7.

What is the expected behavior?

No error.

Most helpful comment

Using macOS/Google Chrome (version 63.0.3239.132), this error is reproducible when you click on the Dropzone element, select an image, let it upload, then render a preview. The console error appears:

index.js?00e3:298 Uncaught TypeError: Cannot read property 'files' of null at eval (index.js?00e3:298)
(anonymous) @ index.js?00e3:298
setTimeout (async)
onFileDialogCancel @ index.js?00e3:296

About to create a PR

All 4 comments

Looks like https://github.com/react-dropzone/react-dropzone/pull/556 introduced a regression. Would you be ready to help fixing it? Probably a null check will suffice.

My heart says yes, my multiple project deadlines say probably not :)

Using macOS/Google Chrome (version 63.0.3239.132), this error is reproducible when you click on the Dropzone element, select an image, let it upload, then render a preview. The console error appears:

index.js?00e3:298 Uncaught TypeError: Cannot read property 'files' of null at eval (index.js?00e3:298)
(anonymous) @ index.js?00e3:298
setTimeout (async)
onFileDialogCancel @ index.js?00e3:296

About to create a PR

Hi,
when will be merge or will be better solution?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

0xdevalias picture 0xdevalias  路  4Comments

imontiel picture imontiel  路  5Comments

xswordsx picture xswordsx  路  3Comments

growthengineering picture growthengineering  路  4Comments

artsx picture artsx  路  4Comments