WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
233555
File DnD event.dataTransfer.items.length is zero in dragenter, over events
https://bugs.webkit.org/show_bug.cgi?id=233555
Summary
File DnD event.dataTransfer.items.length is zero in dragenter, over events
Vishnu
Reported
2021-11-29 05:44:21 PST
Created
attachment 445271
[details]
Issue with Safari The event.dataTransfer.items.length is showing 0 in dragenter and dragover event. Chrome and firefox shows the count of the dataTransferItems. Reproduction steps 1. Open following link in safari
https://codepen.io/rohinikumar4073/pen/poRWvEX?editors=1011
2. Drag and drop files in the red box 3. Observer logs 4. Trying in Chrome the issue is not present
Attachments
Issue with Safari
(64.80 MB, video/mp4)
2021-11-29 05:44 PST
,
Vishnu
no flags
Details
View All
Add attachment
proposed patch, testcase, etc.
Alexey Proskuryakov
Comment 1
2021-11-29 17:16:20 PST
I think that this may be intentional, to prevent web content from sniffing content that is simply dragged over, not intended for it. Not sure though.
Radar WebKit Bug Importer
Comment 2
2021-12-06 05:45:31 PST
<
rdar://problem/86100318
>
alexreardon
Comment 3
2022-08-09 16:46:43 PDT
From the spec:
> A drag data store mode, which is one of the following: > *Read/write mode* > For the dragstart event. New data can be added to the drag data store. > *Read-only mode* > For the drop event. The list of items representing dragged data can be read, including the data. No new data can be added. > *Protected mode* > For all other events. The formats and kinds in the drag data store list of items representing dragged data can be enumerated, but the data itself is unavailable and no new data can be added.
https://html.spec.whatwg.org/multipage/dnd.html#the-drag-data-store
During all drag events other than "dragstart" and "drop" the drag data store (`event.dataTransfer?.items`) should be in *protected mode*. In protected mode, "The formats and kinds in the drag data store list of items representing dragged data can be enumerated, but the data itself is unavailable and no new data can be added.". In Chrome and Firefox, `items` behave according to the spec. However, in Safari, `items` cannot be enumerated. This is problematic for file dragging. For file drag operations, there is no "dragstart" event. So in Safari there is no way to know how many files are being dragged until a "drop" event Reproducible example:
https://codesandbox.io/s/file-drag-and-drop-for-webkit-issue-s94jk1?file=/src/index.ts
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug