From cf9fbce13931732dc4b06d491ef2a01c4921faf1 Mon Sep 17 00:00:00 2001 From: "mathias.stenbom" Date: Mon, 19 Nov 2012 09:06:36 -0500 Subject: [PATCH] Draggable: made handles work with complex markup. Fixes #8757 - Draggable: Resizable handle with inner element does not work, when its also draggable --- tests/unit/draggable/draggable.html | 1 + tests/unit/draggable/draggable_core.js | 29 ++++++++++++++++++++++++++ ui/jquery.ui.draggable.js | 2 +- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/tests/unit/draggable/draggable.html b/tests/unit/draggable/draggable.html index dce226a9a..cd068eb20 100644 --- a/tests/unit/draggable/draggable.html +++ b/tests/unit/draggable/draggable.html @@ -16,6 +16,7 @@ "ui/jquery.ui.core.js", "ui/jquery.ui.widget.js", "ui/jquery.ui.mouse.js", + "ui/jquery.ui.resizable.js", "ui/jquery.ui.draggable.js" ] }); diff --git a/tests/unit/draggable/draggable_core.js b/tests/unit/draggable/draggable_core.js index 31002addc..28a19f380 100644 --- a/tests/unit/draggable/draggable_core.js +++ b/tests/unit/draggable/draggable_core.js @@ -44,4 +44,33 @@ test("No options, absolute", function() { TestHelpers.draggable.shouldMove(el); }); +test("resizable handle with complex markup (#8756 / #8757)", function() { + expect( 2 ); + + $('#draggable1') + .append( + $('
') + .addClass("ui-resizable-handle") + .addClass("ui-resizable-w") + .append($('
')) + ); + + var handle = '.ui-resizable-w div', + target = $('#draggable1').draggable().resizable({ handles: 'all' }), + drag = function(el, dx) { + $(el) + .simulate("mouseover") + .simulate("drag", { + dx: dx || 0, + speed: 'sync' + }); + }; + + drag(handle, -50); + equal( target.width(), 250, "compare width" ); + + drag(handle, 50); + equal( target.width(), 200, "compare width" ); +}); + })(jQuery); diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js index dad5af074..b982ac6be 100644 --- a/ui/jquery.ui.draggable.js +++ b/ui/jquery.ui.draggable.js @@ -70,7 +70,7 @@ $.widget("ui.draggable", $.ui.mouse, { var o = this.options; // among others, prevent a drag on a resizable-handle - if (this.helper || o.disabled || $(event.target).is('.ui-resizable-handle')) { + if (this.helper || o.disabled || $(event.target).closest('.ui-resizable-handle').length > 0) { return false; } -- 2.39.5