electron icon indicating copy to clipboard operation
electron copied to clipboard

[Bug]: HTML Drag and Drop API not returning event.dataTransfer.files array consistently on all Electron versions

Open Ob1To opened this issue 1 year ago • 3 comments

Preflight Checklist

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:

random return

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

Ob1To avatar Apr 26 '24 14:04 Ob1To

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?

dsanders11 avatar May 06 '24 07:05 dsanders11

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 avatar May 07 '24 05:05 Ob1To

@Ob1To does this also happen in Chrome?

codebytere avatar May 15 '24 13:05 codebytere

@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 avatar May 21 '24 09:05 Ob1To

@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.

codebytere avatar May 29 '24 12:05 codebytere

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

Ob1To avatar Jun 03 '24 09:06 Ob1To