From 5afe345954fee4678c9e7145e10260040bb4bba4 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Wed, 16 Nov 2016 10:35:47 +0100 Subject: [PATCH] Droppable: Fix bubbling of greedy droppables - Remove code that made the false assumption that if dragging an element out of the greedy child, it is always over the parent. This is not always true, as the child could be right on the parents border, or even pushed (partially) outside of the parent. - This commit includes the fixes of maimairel, the original author of #9389 from his fiddle http://jsfiddle.net/fvjF4/ Fixes: #9389 --- ui/widgets/droppable.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ui/widgets/droppable.js b/ui/widgets/droppable.js index 89bff2511b7..3aabd957dc0 100644 --- a/ui/widgets/droppable.js +++ b/ui/widgets/droppable.js @@ -420,7 +420,9 @@ $.ui.ddmanager = { if ( parent.length ) { parentInstance = $( parent[ 0 ] ).droppable( "instance" ); - parentInstance.greedyChild = ( c === "isover" ); + parentInstance.greedyChild = + ( typeof parentInstance.movedIntoGreedyChildInthisLoop !== "undefined" ) || + ( c === "isover" ); } } @@ -428,18 +430,18 @@ $.ui.ddmanager = { if ( parentInstance && c === "isover" ) { parentInstance.isover = false; parentInstance.isout = true; + parentInstance.movedIntoGreedyChildInthisLoop = true; parentInstance._out.call( parentInstance, event ); } this[ c ] = true; this[ c === "isout" ? "isover" : "isout" ] = false; this[ c === "isover" ? "_over" : "_out" ].call( this, event ); + } ); - // We just moved out of a greedy child - if ( parentInstance && c === "isout" ) { - parentInstance.isout = false; - parentInstance.isover = true; - parentInstance._over.call( parentInstance, event ); + $.each( $.ui.ddmanager.droppables[ draggable.options.scope ] || [], function() { + if ( typeof this.movedIntoGreedyChildInthisLoop !== "undefined" ) { + delete this.movedIntoGreedyChildInthisLoop; } } );