Skip to content

Commit 11186cc

Browse files
committed
Selectmenu: make sure ui-state-focus class is set on button after initial focus
1 parent 027d8d4 commit 11186cc

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

ui/jquery.ui.selectmenu.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ $.widget( "ui.selectmenu", {
5656
},
5757

5858
_drawButton: function() {
59-
var tabindex = this.element.attr( "tabindex" );
59+
var that = this,
60+
tabindex = this.element.attr( "tabindex" );
6061

6162
// Associate existing label with the new button
6263
this.label = $( "label[for='" + this.ids.element + "']" ).attr( "for", this.ids.button );
@@ -96,6 +97,10 @@ $.widget( "ui.selectmenu", {
9697
this._setOption( "width", this.options.width );
9798

9899
this._on( this.button, this._buttonEvents );
100+
this.button.one( "focusin", function() {
101+
// Delay rendering the menu items until the button receives focus
102+
that._refreshMenu();
103+
});
99104
this._hoverable( this.button );
100105
this._focusable( this.button );
101106
},
@@ -329,13 +334,6 @@ $.widget( "ui.selectmenu", {
329334
},
330335

331336
_buttonEvents: {
332-
focusin: function() {
333-
// Delay rendering the menu items until the button receives focus
334-
if ( !this.menuItems ) {
335-
this._refreshMenu();
336-
}
337-
this._off( this.button, "focusin" );
338-
},
339337
click: "_toggle",
340338
keydown: function( event ) {
341339
var preventDefault = true;

0 commit comments

Comments
 (0)