diff --git a/tests/unit/dialog/options.js b/tests/unit/dialog/options.js index 2de788a4461..17313e07796 100644 --- a/tests/unit/dialog/options.js +++ b/tests/unit/dialog/options.js @@ -569,4 +569,22 @@ QUnit.test( "Open followed by close during show effect", function( assert ) { }, 100 ); } ); +QUnit.test( "Dialog can't break out containment", function( assert ) { + assert.expect( 1 ); + var box = $( '
' ).css( { + height: "500px", border: "0px", margin: "0px", width: "500px", position: "absolute", bottom: "0px", right: "0px", left: "50px", top: "50px" + } ).appendTo( "body" ), + element = $( "
X
" ).dialog( { containment: box, position: { at: "left top", of: box } } ), // open on left top corner + dlg = element.dialog( "widget" ), + offsetAfter, + expected = box.offset(); + + testHelper.drag( element, ".ui-dialog-titlebar", -200, -200 ); // try to move out + offsetAfter = dlg.offset(); // should be the same + assert.deepEqual( offsetAfter, expected, "compare offset" ); + setTimeout( function() { + element.dialog( "close" ); + box.remove(); + }, 100 ); + } ); } ); diff --git a/ui/widgets/dialog.js b/ui/widgets/dialog.js index 6fa585c40db..af148054993 100644 --- a/ui/widgets/dialog.js +++ b/ui/widgets/dialog.js @@ -95,7 +95,8 @@ $.widget( "ui.dialog", { open: null, resize: null, resizeStart: null, - resizeStop: null + resizeStop: null, + containment: "document" }, sizeRelatedOptions: { @@ -547,7 +548,7 @@ $.widget( "ui.dialog", { this.uiDialog.draggable( { cancel: ".ui-dialog-content, .ui-dialog-titlebar-close", handle: ".ui-dialog-titlebar", - containment: "document", + containment: options.containment, start: function( event, ui ) { that._addClass( $( this ), "ui-dialog-dragging" ); that._blockFrames();