@@ -1761,8 +1761,7 @@ the specific language governing permissions and limitations under the Apache Lic
17611761
17621762 var selection ,
17631763 container = this . container ,
1764- dropdown = this . dropdown ,
1765- clickingInside = false ;
1764+ dropdown = this . dropdown ;
17661765
17671766 this . showSearch ( this . opts . minimumResultsForSearch >= 0 ) ;
17681767
@@ -1862,7 +1861,10 @@ the specific language governing permissions and limitations under the Apache Lic
18621861 } ) ) ;
18631862
18641863 selection . bind ( "mousedown" , this . bind ( function ( e ) {
1865- clickingInside = true ;
1864+
1865+ if ( ! this . container . hasClass ( "select2-container-active" ) ) {
1866+ this . opts . element . trigger ( $ . Event ( "select2-focus" ) ) ;
1867+ }
18661868
18671869 if ( this . opened ( ) ) {
18681870 this . close ( ) ;
@@ -1871,8 +1873,6 @@ the specific language governing permissions and limitations under the Apache Lic
18711873 }
18721874
18731875 killEvent ( e ) ;
1874-
1875- clickingInside = false ;
18761876 } ) ) ;
18771877
18781878 dropdown . bind ( "mousedown" , this . bind ( function ( ) { this . search . focus ( ) ; } ) ) ;
@@ -1882,6 +1882,9 @@ the specific language governing permissions and limitations under the Apache Lic
18821882 } ) ) ;
18831883
18841884 this . focusser . bind ( "focus" , this . bind ( function ( ) {
1885+ if ( ! this . container . hasClass ( "select2-container-active" ) ) {
1886+ this . opts . element . trigger ( $ . Event ( "select2-focus" ) ) ;
1887+ }
18851888 this . container . addClass ( "select2-container-active" ) ;
18861889 } ) ) . bind ( "blur" , this . bind ( function ( ) {
18871890 if ( ! this . opened ( ) ) {
@@ -1890,6 +1893,9 @@ the specific language governing permissions and limitations under the Apache Lic
18901893 }
18911894 } ) ) ;
18921895 this . search . bind ( "focus" , this . bind ( function ( ) {
1896+ if ( ! this . container . hasClass ( "select2-container-active" ) ) {
1897+ this . opts . element . trigger ( $ . Event ( "select2-focus" ) ) ;
1898+ }
18931899 this . container . addClass ( "select2-container-active" ) ;
18941900 } ) ) ;
18951901
@@ -2396,13 +2402,19 @@ the specific language governing permissions and limitations under the Apache Lic
23962402 }
23972403 this . selectChoice ( null ) ;
23982404 this . clearPlaceholder ( ) ;
2405+ if ( ! this . container . hasClass ( "select2-container-active" ) ) {
2406+ this . opts . element . trigger ( $ . Event ( "select2-focus" ) ) ;
2407+ }
23992408 this . open ( ) ;
24002409 this . focusSearch ( ) ;
24012410 e . preventDefault ( ) ;
24022411 } ) ) ;
24032412
24042413 this . container . delegate ( selector , "focus" , this . bind ( function ( ) {
24052414 if ( ! this . isInterfaceEnabled ( ) ) return ;
2415+ if ( ! this . container . hasClass ( "select2-container-active" ) ) {
2416+ this . opts . element . trigger ( $ . Event ( "select2-focus" ) ) ;
2417+ }
24062418 this . container . addClass ( "select2-container-active" ) ;
24072419 this . dropdown . addClass ( "select2-drop-active" ) ;
24082420 this . clearPlaceholder ( ) ;
0 commit comments