Open Bug 919631 Opened 7 years ago Updated 5 years ago

drageenter and dragleave are not fired in balanced pairs.

Categories

(Core :: DOM: Events, defect)

24 Branch
x86
macOS
defect
Not set
normal

Tracking

()

UNCONFIRMED

People

(Reporter: alex, Unassigned)

References

()

Details

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.65 Safari/537.36

Steps to reproduce:

See the following jsFiddle: http://jsfiddle.net/a4fet/2/


Actual results:

The number of dragenter events exceeds the number of dragleave events. It seems that 2 dragenter events are fired when the drag begins, and the counter never returns to 0.


Expected results:

The number of dragenter events should equal the number of dragleave events, whenever the draggable is dragged outside of the droppable. This is the behaviour exhibited by Chrome 29.0.1547.65; the counter always returns to 0.
Corrected a typo in the fiddle; use http://jsfiddle.net/a4fet/3/
Component: Untriaged → DOM: Events
Product: Firefox → Core
Alexander, I believe your specific code could be fixed by ignoring events fired on text nodes (which is another bug), but I think the general problem here still exists.

I've put together an example that works in the latest Chrome, Opera, Safari, and IE (both 10 and IE11 preview), but not Firefox.

I'm using a counter to balance out the element's children's `dragenter` and `dragleave` events, but they don't seem to be balanced in Firefox. I believe in some cases the `dragleave` event is firing before the `dragenter` event, but it's hard to tell. Either way, the count is off in Firefox, but not in any other browser.

This is a big problem for detecting when a user has dragged out of an element that contains child elements. A common problem for drag-and-drop file upload pages.
Sorry, I forgot to include my demo:
http://codepen.io/philipwalton/pen/LmcGp
This bug looks like the oddity that I encountered here.
http://ikilote.net/Programmation/JavaScript/DragNDrop/etape6.htm
Move “bloc” and see the console.
You need to log in before you can comment on or make changes to this bug.