@@ -120,7 +120,7 @@ $.widget( "ui.selectmenu", {
120
120
this . menuInstance = this . menu . menu ( {
121
121
role : "listbox" ,
122
122
select : function ( event , ui ) {
123
- event . preventDefault ( ) ;
123
+ event . preventDefault ( ) ;
124
124
that . _select ( ui . item . data ( "ui-selectmenu-item" ) , event ) ;
125
125
} ,
126
126
focus : function ( event , ui ) {
@@ -156,6 +156,11 @@ $.widget( "ui.selectmenu", {
156
156
} ,
157
157
158
158
refresh : function ( ) {
159
+ this . _refreshMenu ( ) ;
160
+ this . _setText ( this . buttonText , this . _getSelectedItem ( ) . text ( ) ) ;
161
+ } ,
162
+
163
+ _refreshMenu : function ( ) {
159
164
this . menu . empty ( ) ;
160
165
161
166
var item ,
@@ -177,8 +182,6 @@ $.widget( "ui.selectmenu", {
177
182
this . menuInstance . focus ( null , item ) ;
178
183
this . _setAria ( item . data ( "ui-selectmenu-item" ) ) ;
179
184
180
- this . _setText ( this . buttonText , item . text ( ) ) ;
181
-
182
185
// Set disabled state
183
186
this . _setOption ( "disabled" , this . element . prop ( "disabled" ) ) ;
184
187
} ,
@@ -190,7 +193,7 @@ $.widget( "ui.selectmenu", {
190
193
191
194
// If this is the first time the menu is being opened, render the items
192
195
if ( ! this . menuItems ) {
193
- this . refresh ( ) ;
196
+ this . _refreshMenu ( ) ;
194
197
} else {
195
198
// TODO: Why is this necessary?
196
199
// Shouldn't the underlying menu always have accurate state?
@@ -320,7 +323,7 @@ $.widget( "ui.selectmenu", {
320
323
focusin : function ( ) {
321
324
// Delay rendering the menu items until the button receives focus
322
325
if ( ! this . menuItems ) {
323
- this . refresh ( ) ;
326
+ this . _refreshMenu ( ) ;
324
327
}
325
328
this . _off ( this . button , "focusin" ) ;
326
329
} ,
0 commit comments