@@ -1775,7 +1775,7 @@ the specific language governing permissions and limitations under the Apache Lic
17751775 container = this . container ,
17761776 dropdown = this . dropdown ;
17771777
1778- this . showSearch ( this . opts . minimumResultsForSearch >= 0 ) ;
1778+ this . showSearch ( false ) ;
17791779
17801780 this . selection = selection = container . find ( ".select2-choice" ) ;
17811781
@@ -2038,12 +2038,13 @@ the specific language governing permissions and limitations under the Apache Lic
20382038 this . highlight ( selected ) ;
20392039 }
20402040
2041- // hide the search box if this is the first we got the results and there are a few of them
2041+ // show the search box if this is the first we got the results and there are enough of them for search
20422042
20432043 if ( initial === true ) {
20442044 var min = this . opts . minimumResultsForSearch ;
2045- showSearchInput = min < 0 ? false : countResults ( data . results ) >= min ;
2046- this . showSearch ( showSearchInput ) ;
2045+ if ( min >= 0 ) {
2046+ this . showSearch ( countResults ( data . results ) >= min ) ;
2047+ }
20472048 }
20482049
20492050 } ,
@@ -2052,9 +2053,10 @@ the specific language governing permissions and limitations under the Apache Lic
20522053 showSearch : function ( showSearchInput ) {
20532054 this . showSearchInput = showSearchInput ;
20542055
2055- this . dropdown . find ( ".select2-search" ) [ showSearchInput ? "removeClass" : "addClass" ] ( "select2-search-hidden" ) ;
2056+ this . dropdown . find ( ".select2-search" ) . toggleClass ( "select2-search-hidden" , ! showSearchInput ) ;
2057+ this . dropdown . find ( ".select2-search" ) . toggleClass ( "select2-offscreen" , ! showSearchInput ) ;
20562058 //add "select2-with-searchbox" to the container if search box is shown
2057- $ ( this . dropdown , this . container ) [ showSearchInput ? "addClass" : "removeClass" ] ( "select2-with-searchbox" ) ;
2059+ $ ( this . dropdown , this . container ) . toggleClass ( "select2-with-searchbox" , showSearchInput ) ;
20582060 } ,
20592061
20602062 // single
0 commit comments