file-selector: [BUG] the version 1.2 introduced a regression

Describe the bug A clear and concise description of what the bug is.

When running the new version of react-dropzone: @14.3.5 link, I noticed a regression introduced in this library

šŸ› This bug was introduced in this commit

The actual error is FileDrop-ky6DIxvn.js:5

TypeError: Cannot read properties of undefined (reading 'getFile')
    at FileDrop-ky6DIxvn.js:1:43484
    at Generator.next (<anonymous>)
    at FileDrop-ky6DIxvn.js:1:386
    at new Promise (<anonymous>)
    at E (FileDrop-ky6DIxvn.js:1:183)
    at FileDrop-ky6DIxvn.js:1:43435
    at async Promise.all (__/index 0)

Accordingly to the experimental documentation of DataTransferItem: getAsFileSystemHandle() method MDN

A Promise. If the item’s kind property is ā€œfileā€, and this item is accessed in the dragstart or drop event handlers, then the returned promise is fulfilled with a FileSystemFileHandle if the dragged item is a file or a FileSystemDirectoryHandle if the dragged item is a directory. Otherwise, the promise fulfills with null.

The return value can be a promise or null, but the current code doesn’t manage null values

Expected behavior A clear and concise description of what you expected to happen. This shouldn’t crash at runtime

Desktop (please complete the following information):

  • userAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36

Additional context Add any other context about the problem here.

It seems that the old/legacy behavior is working as expected.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 17

Commits related to this issue

Most upvoted comments

I can confirm the Fix in 2.1.2 šŸ‘
Thank you @rolandjitsu and @jonkoops

I’ve also filed https://github.com/cypress-io/cypress/issues/30629 to see if the Cypress team can provide any insight.

Once https://github.com/react-dropzone/file-selector/pull/107 goes through, we’ll make a bump in react-dropzone as well.