1- /*
1+ /*
22Copyright 2012 Igor Vaynberg
33
44Version: @@ver@@ Timestamp: @@timestamp@@
@@ -1237,7 +1237,7 @@ the specific language governing permissions and limitations under the Apache Lic
12371237 } ,
12381238
12391239 // abstract
1240- close : function ( keepSearchText ) {
1240+ close : function ( ) {
12411241 if ( ! this . opened ( ) ) return ;
12421242
12431243 var cid = this . containerId ,
@@ -1256,9 +1256,8 @@ the specific language governing permissions and limitations under the Apache Lic
12561256 this . container . removeClass ( "select2-dropdown-open" ) ;
12571257 this . results . empty ( ) ;
12581258
1259- if ( ! keepSearchText ) {
1259+
12601260 this . clearSearch ( ) ;
1261- }
12621261 this . search . removeClass ( "select2-active" ) ;
12631262 this . opts . element . trigger ( $ . Event ( "close" ) ) ;
12641263 } ,
@@ -2150,7 +2149,6 @@ the specific language governing permissions and limitations under the Apache Lic
21502149 " <ul class='select2-choices'>" ,
21512150 //"<li class='select2-search-choice'><span>California</span><a href="javascript:void(0)" class="select2-search-choice-close"></a></li>" ,
21522151 " <li class='select2-search-field'>" ,
2153- " <div class='carret-hider'></div>" ,
21542152 " <input type='text' autocomplete='off' class='select2-input'>" ,
21552153 " </li>" ,
21562154 "</ul>" ,
@@ -2207,8 +2205,6 @@ the specific language governing permissions and limitations under the Apache Lic
22072205
22082206 selectChoice : function ( choice ) {
22092207
2210- this . carretHider . css ( "display" , "none" ) ;
2211-
22122208 var selected = this . container . find ( ".select2-search-choice-focus" ) ;
22132209 if ( selected . length && choice && choice [ 0 ] == selected [ 0 ] ) {
22142210
@@ -2218,10 +2214,9 @@ the specific language governing permissions and limitations under the Apache Lic
22182214 }
22192215 selected . removeClass ( "select2-search-choice-focus" ) ;
22202216 if ( choice && choice . length ) {
2221- this . close ( true ) ;
2217+ this . close ( ) ;
22222218 choice . addClass ( "select2-search-choice-focus" ) ;
22232219 this . opts . element . trigger ( "choice-selected" , choice ) ;
2224- this . carretHider . css ( "display" , "block" ) ;
22252220 }
22262221 }
22272222 } ,
@@ -2233,7 +2228,6 @@ the specific language governing permissions and limitations under the Apache Lic
22332228
22342229 this . searchContainer = this . container . find ( ".select2-search-field" ) ;
22352230 this . selection = selection = this . container . find ( selector ) ;
2236- this . carretHider = $ ( ".carret-hider" , this . container ) ;
22372231
22382232 var _this = this ;
22392233 this . selection . on ( "mousedown" , ".select2-search-choice" , function ( e ) {
@@ -2261,9 +2255,11 @@ the specific language governing permissions and limitations under the Apache Lic
22612255
22622256 this . search . attr ( "tabindex" , this . elementTabIndex ) ;
22632257
2258+ this . keydowns = 0 ;
22642259 this . search . bind ( "keydown" , this . bind ( function ( e ) {
22652260 if ( ! this . enabled ) return ;
22662261
2262+ ++ this . keydowns ;
22672263 var selected = selection . find ( ".select2-search-choice-focus" ) ;
22682264 var prev = selected . prev ( ".select2-search-choice:not(.select2-locked)" ) ;
22692265 var next = selected . next ( ".select2-search-choice:not(.select2-locked)" ) ;
@@ -2296,7 +2292,7 @@ the specific language governing permissions and limitations under the Apache Lic
22962292 this . open ( ) ;
22972293 }
22982294 return ;
2299- } else if ( ( e . which === KEY . BACKSPACE
2295+ } else if ( ( ( e . which === KEY . BACKSPACE && this . keydowns == 1 )
23002296 || e . which == KEY . LEFT ) && ( pos . offset == 0 && ! pos . length ) ) {
23012297
23022298 this . selectChoice ( selection . find ( ".select2-search-choice:not(.select2-locked)" ) . last ( ) ) ;
@@ -2352,7 +2348,11 @@ the specific language governing permissions and limitations under the Apache Lic
23522348
23532349 } ) ) ;
23542350
2355- this . search . bind ( "keyup" , this . bind ( this . resizeSearch ) ) ;
2351+ this . search . bind ( "keyup" , this . bind ( function ( e ) {
2352+ this . keydowns = 0 ;
2353+ this . resizeSearch ( ) ;
2354+ } )
2355+ ) ;
23562356
23572357 this . search . bind ( "blur" , this . bind ( function ( e ) {
23582358 this . container . removeClass ( "select2-container-active" ) ;
0 commit comments