@@ -362,27 +362,27 @@ function SelectDirective($mdSelect, $mdUtil, $mdConstant, $mdTheming, $mdAria, $
362
362
} ;
363
363
364
364
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.
375
368
if ( untouched ) {
376
369
untouched = false ;
377
370
if ( selectScope . _mdSelectIsOpen ) {
378
371
event . stopImmediatePropagation ( ) ;
379
372
}
380
373
}
381
374
382
- if ( selectScope . _mdSelectIsOpen ) return ;
383
375
containerCtrl && containerCtrl . setFocused ( false ) ;
384
376
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 ) ;
386
386
}
387
387
388
388
mdSelectCtrl . triggerClose = function ( ) {
@@ -510,7 +510,6 @@ function SelectDirective($mdSelect, $mdUtil, $mdConstant, $mdTheming, $mdAria, $
510
510
} ) ;
511
511
512
512
513
-
514
513
function inputCheckValue ( ) {
515
514
// The select counts as having a value if one or more options are selected,
516
515
// 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, $
573
572
loadingAsync : attr . mdOnOpen ? scope . $eval ( attr . mdOnOpen ) || true : false
574
573
} ) . finally ( function ( ) {
575
574
selectScope . _mdSelectIsOpen = false ;
576
- element . focus ( ) ;
577
575
element . attr ( 'aria-expanded' , 'false' ) ;
578
576
ngModelCtrl . $setTouched ( ) ;
579
577
} ) ;
0 commit comments