Skip to content

Commit d4551bc

Browse files
committed
Dialog: Respect maxHeight when determining size on open. Fixes #4820 - Dialog: Auto height does not respect the maxHeight option.
1 parent 70b16ef commit d4551bc

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

tests/unit/dialog/dialog_common.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ TestHelpers.commonWidgetTests( "dialog", {
1010
draggable: true,
1111
height: 'auto',
1212
hide: null,
13-
maxHeight: false,
14-
maxWidth: false,
13+
maxHeight: null,
14+
maxWidth: null,
1515
minHeight: 150,
1616
minWidth: 150,
1717
modal: false,

ui/jquery.ui.dialog.js

+10-5
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ $.widget("ui.dialog", {
4848
draggable: true,
4949
hide: null,
5050
height: "auto",
51-
maxHeight: false,
52-
maxWidth: false,
51+
maxHeight: null,
52+
maxWidth: null,
5353
minHeight: 150,
5454
minWidth: 150,
5555
modal: false,
@@ -89,6 +89,7 @@ $.widget("ui.dialog", {
8989
display: this.element[0].style.display,
9090
width: this.element[0].style.width,
9191
minHeight: this.element[0].style.minHeight,
92+
maxHeight: this.element[0].style.maxHeight,
9293
height: this.element[0].style.height
9394
};
9495
this.originalTitle = this.element.attr( "title" );
@@ -632,16 +633,16 @@ $.widget("ui.dialog", {
632633
},
633634

634635
_size: function() {
635-
636636
// If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
637637
// divs will both have width and height set, so we need to reset them
638-
var nonContentHeight, minContentHeight,
638+
var nonContentHeight, minContentHeight, maxContentHeight,
639639
options = this.options;
640640

641641
// reset content sizing
642642
this.element.show().css({
643643
width: "auto",
644644
minHeight: 0,
645+
maxHeight: "none",
645646
height: 0
646647
});
647648

@@ -657,14 +658,18 @@ $.widget("ui.dialog", {
657658
})
658659
.outerHeight();
659660
minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
661+
maxContentHeight = typeof options.maxHeight === "number" ?
662+
Math.max( 0, options.maxHeight - nonContentHeight ) :
663+
"none";
660664

661665
if ( options.height === "auto" ) {
662666
this.element.css({
663667
minHeight: minContentHeight,
668+
maxHeight: maxContentHeight,
664669
height: "auto"
665670
});
666671
} else {
667-
this.element.height( Math.max( options.height - nonContentHeight, 0 ) );
672+
this.element.height( Math.max( 0, options.height - nonContentHeight ) );
668673
}
669674

670675
if (this.uiDialog.is( ":data(ui-resizable)" ) ) {

0 commit comments

Comments
 (0)