Permalink
Browse files

Draggable: Ensure parent is correct after dragging through sortable

Fixes #10669
(cherry picked from commit d8077dc)
  • Loading branch information...
mikesherov authored and scottgonzalez committed Nov 9, 2014
1 parent 189f1d4 commit b3710631e8d21ef9165ef9f037590e1d250350b4
Showing with 29 additions and 2 deletions.
  1. +23 −0 tests/unit/draggable/draggable_options.js
  2. +6 −2 ui/draggable.js
@@ -405,6 +405,29 @@ test( "connectToSortable, dragging through one sortable to a second", function()
element.simulate( "drag", dragParams );
});
test( "connectToSortable, dragging through a sortable", function() {
expect( 1 );
var draggable = $( "#draggableSortable" ).draggable({
scroll: false,
connectToSortable: "#sortable2"
}),
sortable = $( "#sortable2" ).sortable(),
sortableOffset = sortable.offset();
// http://bugs.jqueryui.com/ticket/10669
// Draggable: Position issue with connectToSortable
draggable.one( "dragstop", function() {
equal( draggable.parent().attr( "id" ), "sortable", "restored draggable to original parent" );
});
draggable.simulate( "drag", {
x: sortableOffset.left + 25,
y: sortableOffset.top + sortable.outerHeight() + 400,
moves: 20
});
});
test( "{ containment: Element }", function() {
expect( 1 );
View
@@ -800,6 +800,9 @@ $.ui.plugin.add( "draggable", "connectToSortable", {
if ( !sortable.isOver ) {
sortable.isOver = 1;
// Store draggable's parent in case we need to reappend to it later.
draggable._parent = ui.helper.parent();
sortable.currentItem = ui.helper
.appendTo( sortable.element )
.data( "ui-sortable-item", true );
@@ -876,8 +879,9 @@ $.ui.plugin.add( "draggable", "connectToSortable", {
sortable.placeholder.remove();
}
// Recalculate the draggable's offset considering the sortable
// may have modified them in unexpected ways (#8809)
// Restore and recalculate the draggable's offset considering the sortable
// may have modified them in unexpected ways. (#8809, #10669)
ui.helper.appendTo( draggable._parent );
draggable._refreshOffsets( event );
ui.position = draggable._generatePosition( event, true );

0 comments on commit b371063

Please sign in to comment.