@@ -241,9 +241,16 @@ $.widget("ui.selectmenu", {
241
241
if ( o . style == 'dropdown' ) { this . list . width ( ( o . menuWidth ) ? o . menuWidth : ( ( o . width ) ? o . width : selectWidth ) ) ; }
242
242
else { this . list . width ( ( o . menuWidth ) ? o . menuWidth : ( ( o . width ) ? o . width - o . handleWidth : selectWidth - o . handleWidth ) ) ; }
243
243
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
+ }
247
254
//save reference to actionable li's (not group label li's)
248
255
this . _optionLis = this . list . find ( 'li:not(.' + self . widgetBaseClass + '-group)' ) ;
249
256
@@ -381,7 +388,6 @@ $.widget("ui.selectmenu", {
381
388
var self = this ;
382
389
var disabledStatus = this . newelement . attr ( "aria-disabled" ) ;
383
390
if ( disabledStatus != 'true' ) {
384
- this . _refreshPosition ( ) ;
385
391
this . _closeOthers ( event ) ;
386
392
this . newelement
387
393
. addClass ( 'ui-state-active' ) ;
@@ -392,6 +398,7 @@ $.widget("ui.selectmenu", {
392
398
. attr ( 'aria-hidden' , false )
393
399
. find ( 'li:not(.' + self . widgetBaseClass + '-group):eq(' + this . _selectedIndex ( ) + ') a' ) [ 0 ] . focus ( ) ;
394
400
if ( this . options . style == "dropdown" ) { this . newelement . removeClass ( 'ui-corner-all' ) . addClass ( 'ui-corner-top' ) ; }
401
+ this . _refreshPosition ( ) ;
395
402
this . _trigger ( "open" , event , this . _uiHash ( ) ) ;
396
403
}
397
404
} ,
0 commit comments