Skip to content

Commit

Permalink
fixes ticket #5916, when the dialog uses a padding with an em unit th…
Browse files Browse the repository at this point in the history
…at rounds up, the dialog slowly shrinks because we're resetting the height() whenever a drag event happens. This checkin removes the height() tinkering which stops the dialog from shrinking
  • Loading branch information
fracmak committed May 13, 2011
1 parent c08cf8e commit 85fbeb0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
13 changes: 13 additions & 0 deletions tests/unit/dialog/dialog_tickets.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,17 @@ test("#6966: Escape key closes all dialogs, not the top one", function(){
d1.remove();
});

test("#5916: Dialog: shrinks on drag in IE8 in standards mode", function(){
var d = $('<div id="dialog" title="Basic dialog"><br><br><br><br><br><br><br></div>').dialog({
height:400
});
var dialog = d.parent();
dialog.css("padding", "0.22em").show(); // set the padding to a value that rounds up
var beforeDrag = dialog.height();
dialog.find(".ui-dialog-titlebar").simulate("drag", {dx: 50, dy: -50});
var afterDrag = dialog.height();
equals(afterDrag, beforeDrag);
d.remove();
});

})(jQuery);
8 changes: 2 additions & 6 deletions ui/jquery.ui.dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,7 @@ $.widget("ui.dialog", {
_makeDraggable: function() {
var self = this,
options = self.options,
doc = $( document ),
heightBeforeDrag;
doc = $( document );

function filteredUi( ui ) {
return {
Expand All @@ -384,9 +383,7 @@ $.widget("ui.dialog", {
handle: ".ui-dialog-titlebar",
containment: "document",
start: function( event, ui ) {
heightBeforeDrag = options.height === "auto" ? "auto" : $( this ).height();
$( this )
.height( $( this ).height() )
.addClass( "ui-dialog-dragging" );
self._trigger( "dragStart", event, filteredUi( ui ) );
},
Expand All @@ -399,8 +396,7 @@ $.widget("ui.dialog", {
ui.position.top - doc.scrollTop()
];
$( this )
.removeClass( "ui-dialog-dragging" )
.height( heightBeforeDrag );
.removeClass( "ui-dialog-dragging" );
self._trigger( "dragStop", event, filteredUi( ui ) );
$.ui.dialog.overlay.resize();
}
Expand Down

0 comments on commit 85fbeb0

Please sign in to comment.