[Bug]: HTML Drag and Drop API not returning event.dataTransfer.files array consistently on all Electron versions
Preflight Checklist
- [X] I have read the Contributing Guidelines for this project.
- [X] I agree to follow the Code of Conduct that this project adheres to.
- [X] I have searched the issue tracker for a bug report that matches the one I want to file, without success.
Electron Version
29.1.5
What operating system are you using?
Ubuntu
Operating System Version
Ubuntu 23.10
What arch are you using?
x64
Last Known Working Electron version
No response
Expected Behavior
Consistently return the dropped files - event.dataTransfer.files array so that I can get the file.path property from it.
Actual Behavior
My original project is on Electron 3.1.11 and I'm developing on older Ubuntu 16.04 where I'm testing my code and it's working 100 out of 100 times. On another newer Mint 21.2 it's also working. It is my QA who found that on some new distributions, only some of the times, the drops return the array list populated with information. Most of the times event.dataTransfer.files array is returned empty. It's like some race condition... only on some Linux distributions. I thought that it maybe is related to the old Electron version but I created a blank project with the newest Electron version and it is the same behavior Please check the screenshot where I'm printing in the console the event.dataTransfer.files[0].path property:
Here is also a video of the problem:
https://github.com/electron/electron/assets/6040952/8bae17e1-60ac-49d6-98dc-e41a07a41363
Testcase Gist URL
https://gist.github.com/Ob1To/8adae451dad15605443eda03061601fd
Additional Information
No response
From your repro video it looks like the files that aren't working are executable files, while those that do are text files. Is that just a coincidence in the video, or is that consistent?
From your repro video it looks like the files that aren't working are executable files, while those that do are text files. Is that just a coincidence in the video, or is that consistent?
Unfortunately, it is a coincidence. I have never found any file type correlation. The same behavior is observed with folders also. Randomly receiving the event.dataTransfer.files array..
@Ob1To does this also happen in Chrome?
@Ob1To does this also happen in Chrome?
I was able to test and reproduce the problem within Google Chrome Version 125.0.6422.60 (Official Build) (64-bit). The first 10 times that I dropped a file in the box I received event.dataTransfer.files[0] as undefined. I was going to quit trying but some time after the 10th try I received the event.dataTransfer.files[0] information.
@Ob1To please then report this at https://issues.chromium.org - as it's an upstream issue, the responsibility for fixing it lies with them. When they address it, we'll ingest the changes via our Chromium update process and release them in Electron shortly after.
It seems it is a known issue. I cannot understand if it will ever be fixed: https://issues.chromium.org/issues/40238823 https://issues.chromium.org/issues/40252395