@@ -1627,6 +1627,8 @@ the specific language governing permissions and limitations under the Apache Lic
16271627 dropdown = this . dropdown ,
16281628 clickingInside = false ;
16291629
1630+ this . showSearch ( this . opts . minimumResultsForSearch >= 0 ) ;
1631+
16301632 this . selection = selection = container . find ( ".select2-choice" ) ;
16311633
16321634 this . focusser = container . find ( ".select2-focusser" ) ;
@@ -1691,7 +1693,9 @@ the specific language governing permissions and limitations under the Apache Lic
16911693 this . focusser . bind ( "keyup-change input" , this . bind ( function ( e ) {
16921694 if ( this . opened ( ) ) return ;
16931695 this . open ( ) ;
1694- this . search . val ( this . focusser . val ( ) ) ;
1696+ if ( this . showSearchInput !== false ) {
1697+ this . search . val ( this . focusser . val ( ) ) ;
1698+ }
16951699 this . focusser . val ( "" ) ;
16961700 killEvent ( e ) ;
16971701 } ) ) ;
@@ -1840,15 +1844,22 @@ the specific language governing permissions and limitations under the Apache Lic
18401844 // hide the search box if this is the first we got the results and there are a few of them
18411845
18421846 if ( initial === true ) {
1843- showSearchInput = this . showSearchInput = countResults ( data . results ) >= this . opts . minimumResultsForSearch ;
1844- this . dropdown . find ( ".select2-search" ) [ showSearchInput ? "removeClass" : "addClass" ] ( "select2-search-hidden" ) ;
1845-
1846- //add "select2-with-searchbox" to the container if search box is shown
1847- $ ( this . dropdown , this . container ) [ showSearchInput ? "addClass" : "removeClass" ] ( "select2-with-searchbox" ) ;
1847+ var min = this . opts . minimumResultsForSearch ;
1848+ showSearchInput = min < 0 ? false : countResults ( data . results ) >= min ;
1849+ this . showSearch ( showSearchInput ) ;
18481850 }
18491851
18501852 } ,
18511853
1854+ // single
1855+ showSearch : function ( showSearchInput ) {
1856+ this . showSearchInput = showSearchInput ;
1857+
1858+ this . dropdown . find ( ".select2-search" ) [ showSearchInput ? "removeClass" : "addClass" ] ( "select2-search-hidden" ) ;
1859+ //add "select2-with-searchbox" to the container if search box is shown
1860+ $ ( this . dropdown , this . container ) [ showSearchInput ? "addClass" : "removeClass" ] ( "select2-with-searchbox" ) ;
1861+ } ,
1862+
18521863 // single
18531864 onSelect : function ( data , options ) {
18541865 var old = this . opts . element . val ( ) ;
0 commit comments