diff --git a/tests/unit/sortable/sortable_options.js b/tests/unit/sortable/sortable_options.js index f2beb4dbcd6..fcc47b83b6d 100644 --- a/tests/unit/sortable/sortable_options.js +++ b/tests/unit/sortable/sortable_options.js @@ -116,6 +116,31 @@ test("{ cancel: Selector }", function() { }); */ +test( "#9443: Could not drag any but last item toward last position from initially empty floated sortable with { axis: 'x' }", function() { + expect(1); + var item, i, + changeCount = 0, + element = $( "#sortable" ).empty().sortable({ + axis: "x", + change: function() { + changeCount++; + } + }); + + for(i = 0; i < 5; i++) { + element.append( "
  • Item " + i + "
  • " ); + } + + item = element.find( "li" ).css( "float", "left" ).eq( -2 ); + + item.simulate( "drag", { + dx: 50, + dy: 0, + moves: 1 + }); + equal( changeCount, 1, "change fired once when dragging a floated sortable in it's own container" ); +}); + test( "#8792: issues with floated items in connected lists", function() { expect( 2 ); diff --git a/ui/jquery.ui.sortable.js b/ui/jquery.ui.sortable.js index 9c7bf446cda..a196b6969cb 100644 --- a/ui/jquery.ui.sortable.js +++ b/ui/jquery.ui.sortable.js @@ -75,7 +75,7 @@ $.widget("ui.sortable", $.ui.mouse, { this.refresh(); //Let's determine if the items are being displayed horizontally - this.floating = this.items.length ? o.axis === "x" || isFloating(this.items[0].item) : false; + this.floating = o.axis === "x" || (this.items.length ? isFloating(this.items[0].item) : false); //Let's determine the parent's offset this.offset = this.element.offset();