@@ -362,27 +362,27 @@ function SelectDirective($mdSelect, $mdUtil, $mdConstant, $mdTheming, $mdAria, $
362362 } ;
363363
364364 if ( ! isReadonly ) {
365- element
366- . on ( 'focus' , function ( ev ) {
367- // Always focus the container (if we have one) so floating labels and other styles are
368- // applied properly
369- containerCtrl && containerCtrl . setFocused ( true ) ;
370- } ) ;
371-
372- // Attach before ngModel's blur listener to stop propagation of blur event
373- // to prevent from setting $touched.
374- element . on ( 'blur' , function ( event ) {
365+ var handleBlur = function ( event ) {
366+ // Attach before ngModel's blur listener to stop propagation of blur event
367+ // and prevent setting $touched.
375368 if ( untouched ) {
376369 untouched = false ;
377370 if ( selectScope . _mdSelectIsOpen ) {
378371 event . stopImmediatePropagation ( ) ;
379372 }
380373 }
381374
382- if ( selectScope . _mdSelectIsOpen ) return ;
383375 containerCtrl && containerCtrl . setFocused ( false ) ;
384376 inputCheckValue ( ) ;
385- } ) ;
377+ } ;
378+ var handleFocus = function ( ev ) {
379+ // Always focus the container (if we have one) so floating labels and other styles are
380+ // applied properly
381+ containerCtrl && containerCtrl . setFocused ( true ) ;
382+ } ;
383+
384+ element . on ( 'focus' , handleFocus ) ;
385+ element . on ( 'blur' , handleBlur ) ;
386386 }
387387
388388 mdSelectCtrl . triggerClose = function ( ) {
@@ -510,7 +510,6 @@ function SelectDirective($mdSelect, $mdUtil, $mdConstant, $mdTheming, $mdAria, $
510510 } ) ;
511511
512512
513-
514513 function inputCheckValue ( ) {
515514 // The select counts as having a value if one or more options are selected,
516515 // or if the input's validity state says it has bad input (eg string in a number input)
@@ -573,7 +572,6 @@ function SelectDirective($mdSelect, $mdUtil, $mdConstant, $mdTheming, $mdAria, $
573572 loadingAsync : attr . mdOnOpen ? scope . $eval ( attr . mdOnOpen ) || true : false
574573 } ) . finally ( function ( ) {
575574 selectScope . _mdSelectIsOpen = false ;
576- element . focus ( ) ;
577575 element . attr ( 'aria-expanded' , 'false' ) ;
578576 ngModelCtrl . $setTouched ( ) ;
579577 } ) ;
0 commit comments