From cf66dd56fa989e5435df61b32e55ebc26efe90a0 Mon Sep 17 00:00:00 2001 From: Julien Sanchez Date: Mon, 22 Jul 2013 08:55:14 +0200 Subject: [PATCH 1/2] Fix floating detection when sortable is initially empty (#9443) --- tests/unit/sortable/sortable_options.js | 25 +++++++++++++++++++++++++ ui/jquery.ui.sortable.js | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/tests/unit/sortable/sortable_options.js b/tests/unit/sortable/sortable_options.js index f2beb4dbcd6..2be1bf404d7 100644 --- a/tests/unit/sortable/sortable_options.js +++ b/tests/unit/sortable/sortable_options.js @@ -116,6 +116,31 @@ test("{ cancel: Selector }", function() { }); */ +test( "#xxxx: 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(); From 547c9da3324998eab52923814078e9013edf1097 Mon Sep 17 00:00:00 2001 From: Julien Sanchez Date: Mon, 22 Jul 2013 10:11:44 +0200 Subject: [PATCH 2/2] Add issue ID --- tests/unit/sortable/sortable_options.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/sortable/sortable_options.js b/tests/unit/sortable/sortable_options.js index 2be1bf404d7..fcc47b83b6d 100644 --- a/tests/unit/sortable/sortable_options.js +++ b/tests/unit/sortable/sortable_options.js @@ -116,7 +116,7 @@ test("{ cancel: Selector }", function() { }); */ -test( "#xxxx: Could not drag any but last item toward last position from initially empty floated sortable with { axis: 'x' }", 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,