Skip to content

Commit 3576ceb

Browse files
committed
Resizable: Remove bad workaround for draggable+resizable
This adds a compound test page for draggable+resizable, which had no coverage before. Using that page shows that there is no way to reproduce the behaviour described in the original ticket that caused this workaround, since its not possible to resize an element beyond the window boundaries. Therefore removing the workaround, which is 6+ years old and has no test coverage, seems like the sanest approach. Fixes #6939 Closes gh-1210
1 parent 919d918 commit 3576ceb

File tree

4 files changed

+58
-12
lines changed

4 files changed

+58
-12
lines changed

tests/unit/resizable/resizable_core.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,14 @@ test("handle with complex markup (#8756)", function() {
171171
});
172172

173173
test("resizable accounts for scroll position correctly (#3815)", function() {
174-
expect( 3 );
174+
expect( 4 );
175175

176176
var position, top, left,
177177
container = $("<div style='overflow:scroll;height:300px;width:300px;position:relative;'></div>").appendTo("#qunit-fixture"),
178178
overflowed = $("<div style='width: 1000px; height: 1000px;'></div>").appendTo( container ),
179179
el = $("<div style='height:100px;width:100px;position:absolute;top:10px;left:10px;'></div>").appendTo( overflowed ).resizable({ handles: "all" }),
180-
handle = ".ui-resizable-e";
180+
handle = ".ui-resizable-e",
181+
handlePosition = $(handle).position().left;
181182

182183
container.scrollLeft( 100 ).scrollTop( 100 );
183184

@@ -189,6 +190,7 @@ test("resizable accounts for scroll position correctly (#3815)", function() {
189190
deepEqual( el.position(), position, "position stays the same when resized" );
190191
equal( el.css("left"), left, "css('left') stays the same when resized" );
191192
equal( el.css("top"), top, "css('top') stays the same when resized" );
193+
equal( $(handle).position().left, handlePosition + 50, "handle also moved" );
192194
});
193195

194196
test( "resizable stores correct size when using helper and grid (#9547)", function() {
@@ -208,7 +210,7 @@ test( "resizable stores correct size when using helper and grid (#9547)", functi
208210

209211
test( "nested resizable", function() {
210212
expect( 4 );
211-
213+
212214
var outer = $( "<div id='outer' style='width:50px'></div>" ),
213215
inner = $( "<div id='inner' style='width:30px'></div>" ),
214216
target = $( "#resizable1" ),
@@ -224,7 +226,7 @@ test( "nested resizable", function() {
224226

225227
innerHandle = $( "#inner > .ui-resizable-e" );
226228
outerHandle = $( "#outer > .ui-resizable-e" );
227-
229+
228230
TestHelpers.resizable.drag( innerHandle, 10 );
229231
equal( inner.width(), 40, "compare width of inner element" );
230232
TestHelpers.resizable.drag( innerHandle, -10 );
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Compound Visual Test: Draggable and Resizable block element</title>
6+
<link rel="stylesheet" href="../visual.css">
7+
<link rel="stylesheet" href="../../../themes/base/all.css">
8+
<script src="../../../jquery.js"></script>
9+
<script src="../../../ui/core.js"></script>
10+
<script src="../../../ui/widget.js"></script>
11+
<script src="../../../ui/mouse.js"></script>
12+
<script src="../../../ui/draggable.js"></script>
13+
<script src="../../../ui/resizable.js"></script>
14+
<style>
15+
.draggable {
16+
margin: 0.5em;
17+
padding: 0.5em;
18+
}
19+
.absolute {
20+
color: red;
21+
position: absolute !important;
22+
}
23+
</style>
24+
<script>
25+
$(function() {
26+
$( ".draggable" )
27+
.addClass( "ui-widget ui-widget-header ui-corner-all" )
28+
.draggable({
29+
revert: "invalid"
30+
})
31+
.resizable({
32+
minHeight: 13,
33+
handles: "s"
34+
});
35+
$( ".draggable:last" ).addClass( "absolute" );
36+
});
37+
</script>
38+
</head>
39+
<body>
40+
41+
<p>WHAT: Three draggable and resizable elements, with only a bottom handle. Last one (red color) is absolutely positioned.</p>
42+
<p>EXPECTED: Each element can be dragged and resized. The first two stay with their relative positioning (induced by draggable). The last one can be resized despite the absolute positioning.</p>
43+
44+
<div id="first">
45+
<div class="draggable">Draggable 1-1</div>
46+
<div class="draggable">Draggable 1-2</div>
47+
<div class="draggable">Draggable 1-3</div>
48+
</div>
49+
50+
</body>
51+
</html>

tests/visual/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ <h2>Compound</h2>
7575
<li><a href="compound/dialog_widgets.html">Various Widgets in Dialog</a></li>
7676
<li><a href="compound/draggable_accordion.html">Draggable Accordion</a></li>
7777
<li><a href="compound/draggable_accordion_accordion_tabs_draggable.html">Nested Widgets</a></li>
78+
<li><a href="compound/draggable_resizable.html">Draggable Resizable</a></li>
7879
<li><a href="compound/sortable_accordion_sortable_tabs.html">Sortable Tabs in Sortable Accordion</a></li>
7980
<li><a href="compound/tabs_tabs.html">Nested Tabs</a></li>
8081
<li><a href="compound/tabs_tooltips.html">Tabs with Tooltips</a></li>

ui/resizable.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -287,18 +287,10 @@ $.widget("ui.resizable", $.ui.mouse, {
287287

288288
var curleft, curtop, cursor,
289289
o = this.options,
290-
iniPos = this.element.position(),
291290
el = this.element;
292291

293292
this.resizing = true;
294293

295-
// Bugfix for http://bugs.jqueryui.com/ticket/1749
296-
if ( (/absolute/).test( el.css("position") ) ) {
297-
el.css({ position: "absolute", top: el.css("top"), left: el.css("left") });
298-
} else if (el.is(".ui-draggable")) {
299-
el.css({ position: "absolute", top: iniPos.top, left: iniPos.left });
300-
}
301-
302294
this._renderProxy();
303295

304296
curleft = this._num(this.helper.css("left"));

0 commit comments

Comments
 (0)