Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dragging text to drop zone produces error: Cannot read property 'isFile' of null #22

Closed
EnigmaticaGH opened this issue Nov 7, 2017 · 2 comments

Comments

@EnigmaticaGH
Copy link

ERROR TypeError: Cannot read property 'isFile' of null

Tested on Chrome latest by dragging text from my website to the drop zone.

The code where the error is present:

    for (var i = 0; i < length; i++) {
      var entry;
      if (event.dataTransfer.items) {
        if (event.dataTransfer.items[i].webkitGetAsEntry) {
          entry = event.dataTransfer.items[i].webkitGetAsEntry();
        }
      } else {
        if (event.dataTransfer.files[i].webkitGetAsEntry) {
          entry = event.dataTransfer.files[i].webkitGetAsEntry()
        }
      }

      if (entry.isFile) { // <--- Error occurs here
        const toUpload: UploadFile = new UploadFile(entry.name, entry);
        this.addToQueue(toUpload);
      } else if (entry.isDirectory) {
        this.traverseFileTree(entry, entry.name);
      }
    }

Solution:

Check if entry is null before checking entry.isFile

@maartenmensink
Copy link
Contributor

@georgipeltekov what should be the expected behavior?

@georgipeltekov
Copy link
Owner

I think we just need to ignore this case

maartenmensink added a commit to SpringIT/ngx-file-drop that referenced this issue Nov 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants