Skip to content

Commit eaef468

Browse files
committed
fixed: hopefully some issues with positioning and jumping, see: fnagel#147
1 parent 9c9425a commit eaef468

File tree

2 files changed

+27
-19
lines changed

2 files changed

+27
-19
lines changed

themes/base/jquery.ui.selectmenu.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
----------------------------------*/
33
.ui-selectmenu { display: block; display: inline-block; position: relative; height: 2.2em; vertical-align: middle; text-decoration: none; overflow: hidden; zoom: 1; }
44
.ui-selectmenu-icon { position:absolute; right:6px; margin-top:-8px; top: 50%; }
5-
.ui-selectmenu-menu { padding:0; margin:0; position:absolute; display: none; z-index: 1005;} /* z-index: 1005 to make selectmenu work with dialog */
5+
.ui-selectmenu-menu { padding:0; margin:0; position:absolute; top: 0; display: none; z-index: 1005;} /* z-index: 1005 to make selectmenu work with dialog */
66
.ui-selectmenu-menu ul { padding:0; margin:0; list-style:none; position: relative; overflow: auto; overflow-y: auto ; overflow-x: hidden; }
77
.ui-selectmenu-open { display: block; }
88
.ui-selectmenu-menu-popup { margin-top: -1px; }

ui/jquery.ui.selectmenu.js

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,10 @@ $.widget("ui.selectmenu", {
253253
// this allows for using the scrollbar in an overflowed list
254254
.bind( 'mousedown.selectmenu mouseup.selectmenu', function() { return false; });
255255

256-
257256
// needed when window is resized
258-
$(window).bind( "resize.selectmenu", $.proxy( self._refreshPosition, this ) );
257+
// TODO seems to be useless, but causes errors (fnagel 01.08.11)
258+
// see: https://github.com/fnagel/jquery-ui/issues/147
259+
// $(window).bind( "resize.selectmenu", $.proxy( self._refreshPosition, this ) );
259260
},
260261

261262
_init: function() {
@@ -424,7 +425,8 @@ $.widget("ui.selectmenu", {
424425
.removeAttr( 'aria-disabled' )
425426
.unbind( ".selectmenu" );
426427

427-
$( window ).unbind( ".selectmenu" );
428+
// TODO unneded as event binding has been disabled
429+
// $( window ).unbind( ".selectmenu" );
428430
$( document ).unbind( ".selectmenu" );
429431

430432
// unbind click on label, reset its for attr
@@ -513,21 +515,26 @@ $.widget("ui.selectmenu", {
513515
var self = this, o = this.options;
514516
if ( self.newelement.attr("aria-disabled") != 'true' ) {
515517
self._closeOthers(event);
516-
self.newelement
517-
.addClass('ui-state-active');
518+
self.newelement.addClass('ui-state-active');
518519

519520
self.listWrap.appendTo( o.appendTo );
520-
521-
self.listWrap.addClass( self.widgetBaseClass + '-open' );
522-
523-
selected = self.list.attr('aria-hidden', false).find('li:not(.' + self.widgetBaseClass + '-group):eq(' + self._selectedIndex() + ') a');
524-
if (selected.length) selected[0].focus();
521+
self.list.attr('aria-hidden', false)
525522

526523
if ( o.style == "dropdown" ) {
527524
self.newelement.removeClass('ui-corner-all').addClass('ui-corner-top');
528525
}
529526

530-
self._refreshPosition();
527+
self.listWrap.addClass( self.widgetBaseClass + '-open' );
528+
// positioning needed for IE7 (tested 01.08.11 on MS VPC Image)
529+
// see https://github.com/fnagel/jquery-ui/issues/147
530+
if ( $.browser.msie && $.browser.version.substr( 0,1 ) == 7 ) {
531+
self._refreshPosition();
532+
}
533+
selected = self.list.attr('aria-hidden', false).find('li:not(.' + self.widgetBaseClass + '-group):eq(' + self._selectedIndex() + ') a');
534+
if (selected.length) selected[0].focus();
535+
// positioning needed for FF, Chrome, IE8, IE7, IE6 (tested 01.08.11 on MS VPC Image)
536+
self._refreshPosition();
537+
531538
self._trigger("open", event, self._uiHash());
532539
}
533540
},
@@ -794,6 +801,7 @@ $.widget("ui.selectmenu", {
794801

795802
_refreshPosition: function() {
796803
var o = this.options;
804+
797805
// if its a native pop-up we need to calculate the position of the selected li
798806
if (o.style == "popup" && !o.positionOptions.offset) {
799807
var selected = this._selectedOptionLi();
@@ -807,13 +815,13 @@ $.widget("ui.selectmenu", {
807815
});
808816
}
809817
this.listWrap.position({
810-
// set options for position plugin
811-
of: o.positionOptions.of || this.newelement,
812-
my: o.positionOptions.my,
813-
at: o.positionOptions.at,
814-
offset: o.positionOptions.offset || _offset,
815-
collision: o.positionOptions.collision || 'flip'
816-
});
818+
// set options for position plugin
819+
of: o.positionOptions.of || this.newelement,
820+
my: o.positionOptions.my,
821+
at: o.positionOptions.at,
822+
offset: o.positionOptions.offset || _offset,
823+
collision: o.positionOptions.collision || 'flip'
824+
});
817825
}
818826
});
819827

0 commit comments

Comments
 (0)