Skip to content

dragenter canceling is not required for the element to be a drop target? #11608

@Josh-Cena

Description

@Josh-Cena

What is the issue with the HTML Standard?

If I'm reading https://html.spec.whatwg.org/multipage/dnd.html#drag-and-drop-processing-model correctly, in the ongoing processing step 3.1, we can only ever set current target for which one of these is true: (a) non-DOM (b) canceled dragenter (c) is a text input (d) is the body element. Afterwards, it is only possible for dragleave to fire on a target element. However, in all three browsers I tested, dragleave fires on all DOM elements, regardless if they've elected to become a target by canceling dragenter. Here's the minimum code:

<p id="p1" draggable="true">This element is draggable.</p>
<p id="foo">Foo</p>
<p id="bar">Bar</p>
foo.ondragleave = (e) => console.log("dragleave", e.target);
bar.ondragleave = (e) => console.log("dragleave", e.target);

I see the events firing. It seems that for all browsers, the only requirement for drop to happen is for dragover to be canceled (which is also not supposed to fire on these elements!). I'm not sure if this is Mac-specific behavior.

Furthermore I'm slightly confused about these two statements:

To my naïve eyes, if I'm moving directly from a drop target to the body, I would expect current target to become body anyway, but this algorithm seems to say that the target should remain that drop target.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions