File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1716,11 +1716,24 @@ the specific language governing permissions and limitations under the Apache Lic
17161716
17171717 // single
17181718 opening : function ( ) {
1719+ var el , range ;
17191720 this . parent . opening . apply ( this , arguments ) ;
17201721 if ( this . showSearchInput !== false ) {
1722+ // IE appends focusser.val() at the end of field :/ so we manually insert it at the beginning using a range
1723+ // all other browsers handle this just fine
1724+
17211725 this . search . val ( this . focusser . val ( ) ) ;
17221726 }
17231727 this . search . focus ( ) ;
1728+ // in IE we have to move the cursor to the end after focussing, otherwise it will be at the beginning and
1729+ // new text will appear *before* focusser.val()
1730+ el = this . search . get ( 0 ) ;
1731+ if ( el . createTextRange ) {
1732+ range = el . createTextRange ( ) ;
1733+ range . collapse ( false ) ;
1734+ range . select ( ) ;
1735+ }
1736+
17241737 this . focusser . prop ( "disabled" , true ) . val ( "" ) ;
17251738 this . updateResults ( true ) ;
17261739 this . opts . element . trigger ( $ . Event ( "select2-open" ) ) ;
You can’t perform that action at this time.
0 commit comments