Skip to content

Commit c5770c0

Browse files
Ziling Zhaoscottgonzalez
Ziling Zhao
authored andcommitted
Dialog: modified so that minWidth is respected. Fixes #5531 - dialog width should be at least minWidth on creation.
1 parent 90caa93 commit c5770c0

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

tests/unit/dialog/dialog_tickets.js

+21
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,25 @@ test("#5184: isOpen in dialogclose event is true", function() {
4040
el.remove();
4141
});
4242

43+
test("#5531: dialog width should be at least minWidth on creation", function () {
44+
el = $('<div></div>').dialog({
45+
width: 200,
46+
minWidth: 300
47+
});
48+
49+
equals(el.dialog('option', 'width'), 300, "width is minWidth");
50+
el.dialog('option', 'width', 200);
51+
equals(el.dialog('option', 'width'), 300, "width unchanged when set to < minWidth");
52+
el.dialog('option', 'width', 320);
53+
equals(el.dialog('option', 'width'), 320, "width changed if set to > minWidth");
54+
el.remove();
55+
56+
el = $('<div></div>').dialog({
57+
minWidth: 300
58+
});
59+
ok(el.dialog('option', 'width') >= 300, "width is at least 300");
60+
el.remove();
61+
62+
});
63+
4364
})(jQuery);

ui/jquery.ui.dialog.js

+4
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,10 @@ $.widget("ui.dialog", {
628628
height: 0
629629
});
630630

631+
if (options.minWidth > options.width) {
632+
options.width = options.minWidth;
633+
}
634+
631635
// reset wrapper sizing
632636
// determine the height of all the non-content elements
633637
nonContentHeight = this.uiDialog.css({

0 commit comments

Comments
 (0)