@@ -120,7 +120,7 @@ $.widget( "ui.selectmenu", {
120120 this . menuInstance = this . menu . menu ( {
121121 role : "listbox" ,
122122 select : function ( event , ui ) {
123- event . preventDefault ( ) ;
123+ event . preventDefault ( ) ;
124124 that . _select ( ui . item . data ( "ui-selectmenu-item" ) , event ) ;
125125 } ,
126126 focus : function ( event , ui ) {
@@ -156,6 +156,11 @@ $.widget( "ui.selectmenu", {
156156 } ,
157157
158158 refresh : function ( ) {
159+ this . _refreshMenu ( ) ;
160+ this . _setText ( this . buttonText , this . _getSelectedItem ( ) . text ( ) ) ;
161+ } ,
162+
163+ _refreshMenu : function ( ) {
159164 this . menu . empty ( ) ;
160165
161166 var item ,
@@ -177,8 +182,6 @@ $.widget( "ui.selectmenu", {
177182 this . menuInstance . focus ( null , item ) ;
178183 this . _setAria ( item . data ( "ui-selectmenu-item" ) ) ;
179184
180- this . _setText ( this . buttonText , item . text ( ) ) ;
181-
182185 // Set disabled state
183186 this . _setOption ( "disabled" , this . element . prop ( "disabled" ) ) ;
184187 } ,
@@ -190,7 +193,7 @@ $.widget( "ui.selectmenu", {
190193
191194 // If this is the first time the menu is being opened, render the items
192195 if ( ! this . menuItems ) {
193- this . refresh ( ) ;
196+ this . _refreshMenu ( ) ;
194197 } else {
195198 // TODO: Why is this necessary?
196199 // Shouldn't the underlying menu always have accurate state?
@@ -320,7 +323,7 @@ $.widget( "ui.selectmenu", {
320323 focusin : function ( ) {
321324 // Delay rendering the menu items until the button receives focus
322325 if ( ! this . menuItems ) {
323- this . refresh ( ) ;
326+ this . _refreshMenu ( ) ;
324327 }
325328 this . _off ( this . button , "focusin" ) ;
326329 } ,
0 commit comments