[Webkit-unassigned] [Bug 223517] New: DataTransferItemList is empty during dragenter/dragover events when dragging files

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Mar 19 08:07:57 PDT 2021


https://bugs.webkit.org/show_bug.cgi?id=223517

            Bug ID: 223517
           Summary: DataTransferItemList is empty during
                    dragenter/dragover events when dragging files
           Product: WebKit
           Version: Safari 14
          Hardware: Unspecified
                OS: macOS 10.15
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: UI Events
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: govett at adobe.com

When dragging files from Finder or elsewhere over an element, the dragenter/dragover events fire as expected, but the `e.dataTransfer.items` list is empty. This means that it's impossible to only accept drops of certain file types. The only information available is that the `dataTransfer.types` property includes "Files", but this doesn't tell us the actual file types. While I wouldn't expect to be able to read the dragged content until drop, I would expect to be able to read their types to determine if the drop should be accepted. In both Chrome and Firefox the `items` list includes DataTransferItem objects that include a `kind` of "file" and a `type` property containing the mime type of the files being dragged. In addition, when dragging non-files (e.g. the `kind` is "string"), the items list is not empty and does allow access to the types.

Steps to reproduce:

1. Open https://codepen.io/devongovett/pen/jOVjRdJ
2. Drag a PNG file from Finder over the drop zone.
3. Notice that the drop zone does not turn green because the `e.dataTransfer.items` list does not contain any items with type "image/png". Dropping the file also does nothing. The result is that no files can be dropped.
4. Open the same page in Chrome and Firefox. Notice that it does turn green when dragging a PNG file over the drop zone. Also notice that it does not turn green when dragging non PNG files over the drop zone.

Looking at the spec, I think the data transfer should be in protected mode during these events rather than disabled mode. This means the list of items can be enumerated, but the actual data is not readable. See https://html.spec.whatwg.org/multipage/dnd.html#drag-data-store. See also https://html.spec.whatwg.org/multipage/dnd.html#dndevents.

Unfortunately, the only workaround to this bug is not to filter by file type at all, and instead accept drops of all file types. This leads to a sub-optimal user experience where drop zones highlight to indicate that a user can drop files there but on drop nothing happens or an error message must be shown to indicate that the files were not accepts. If this bug were fixed, we could only highlight the drop zone when supported files are dragged.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20210319/010c5862/attachment-0001.htm>


More information about the webkit-unassigned mailing list