Skip to content

Commit cf9fbce

Browse files
MatteS75mikesherov
authored andcommitted
Draggable: made handles work with complex markup. Fixes #8757 - Draggable: Resizable handle with inner element does not work, when its also draggable
1 parent cc7df71 commit cf9fbce

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

tests/unit/draggable/draggable.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"ui/jquery.ui.core.js",
1717
"ui/jquery.ui.widget.js",
1818
"ui/jquery.ui.mouse.js",
19+
"ui/jquery.ui.resizable.js",
1920
"ui/jquery.ui.draggable.js"
2021
]
2122
});

tests/unit/draggable/draggable_core.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,33 @@ test("No options, absolute", function() {
4444
TestHelpers.draggable.shouldMove(el);
4545
});
4646

47+
test("resizable handle with complex markup (#8756 / #8757)", function() {
48+
expect( 2 );
49+
50+
$('#draggable1')
51+
.append(
52+
$('<div>')
53+
.addClass("ui-resizable-handle")
54+
.addClass("ui-resizable-w")
55+
.append($('<div>'))
56+
);
57+
58+
var handle = '.ui-resizable-w div',
59+
target = $('#draggable1').draggable().resizable({ handles: 'all' }),
60+
drag = function(el, dx) {
61+
$(el)
62+
.simulate("mouseover")
63+
.simulate("drag", {
64+
dx: dx || 0,
65+
speed: 'sync'
66+
});
67+
};
68+
69+
drag(handle, -50);
70+
equal( target.width(), 250, "compare width" );
71+
72+
drag(handle, 50);
73+
equal( target.width(), 200, "compare width" );
74+
});
75+
4776
})(jQuery);

ui/jquery.ui.draggable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ $.widget("ui.draggable", $.ui.mouse, {
7070
var o = this.options;
7171

7272
// among others, prevent a drag on a resizable-handle
73-
if (this.helper || o.disabled || $(event.target).is('.ui-resizable-handle')) {
73+
if (this.helper || o.disabled || $(event.target).closest('.ui-resizable-handle').length > 0) {
7474
return false;
7575
}
7676

0 commit comments

Comments
 (0)