Skip to content

Commit 04876d3

Browse files
committed
fixed: positioning issue
added: default max height based upon the viewport height
1 parent b6ce8d6 commit 04876d3

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

ui/jquery.ui.selectmenu.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,16 @@ $.widget("ui.selectmenu", {
241241
if(o.style == 'dropdown'){ this.list.width( (o.menuWidth) ? o.menuWidth : ((o.width) ? o.width : selectWidth)); }
242242
else { this.list.width( (o.menuWidth) ? o.menuWidth : ((o.width) ? o.width - o.handleWidth : selectWidth - o.handleWidth)); }
243243

244-
//set max height from option
245-
if(o.maxHeight && o.maxHeight < this.list.height()){ this.list.height(o.maxHeight); }
246-
244+
// calculate default max height
245+
if(o.maxHeight) {
246+
//set max height from option
247+
if (o.maxHeight < this.list.height()){ this.list.height(o.maxHeight); }
248+
} else {
249+
if (($(window).height() / 3) < this.list.height()) {
250+
o.maxHeight = $(window).height() / 3
251+
this.list.height(o.maxHeight);
252+
}
253+
}
247254
//save reference to actionable li's (not group label li's)
248255
this._optionLis = this.list.find('li:not(.'+ self.widgetBaseClass +'-group)');
249256

@@ -381,7 +388,6 @@ $.widget("ui.selectmenu", {
381388
var self = this;
382389
var disabledStatus = this.newelement.attr("aria-disabled");
383390
if(disabledStatus != 'true'){
384-
this._refreshPosition();
385391
this._closeOthers(event);
386392
this.newelement
387393
.addClass('ui-state-active');
@@ -392,6 +398,7 @@ $.widget("ui.selectmenu", {
392398
.attr('aria-hidden', false)
393399
.find('li:not(.'+ self.widgetBaseClass +'-group):eq('+ this._selectedIndex() +') a')[0].focus();
394400
if(this.options.style == "dropdown"){ this.newelement.removeClass('ui-corner-all').addClass('ui-corner-top'); }
401+
this._refreshPosition();
395402
this._trigger("open", event, this._uiHash());
396403
}
397404
},

0 commit comments

Comments
 (0)