Skip to content

Commit

Permalink
fix(select): set the focus to false if the model is undefined or if t…
Browse files Browse the repository at this point in the history
…he model was added without focus.

Fixes angular#6122
  • Loading branch information
devversion committed Dec 7, 2015
1 parent f73ef23 commit e49951c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/components/select/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ function SelectDirective($mdSelect, $mdUtil, $mdTheming, $mdAria, $compile, $par
syncLabelText();
syncAriaLabel();
inputCheckValue();
inputCheckFocus();
};

attr.$observe('placeholder', ngModelCtrl.$render);
Expand Down Expand Up @@ -344,6 +345,7 @@ function SelectDirective($mdSelect, $mdUtil, $mdTheming, $mdAria, $compile, $par
syncLabelText();
syncAriaLabel();
inputCheckValue();
inputCheckFocus();
};
ngModelCtrl.$render();
}
Expand Down Expand Up @@ -408,6 +410,11 @@ function SelectDirective($mdSelect, $mdUtil, $mdTheming, $mdAria, $compile, $par
containerCtrl && containerCtrl.setHasValue(selectMenuCtrl.selectedLabels().length > 0 || (element[0].validity || {}).badInput);
}

function inputCheckFocus() {
// We should set the focus to false if the model is undefined or if the model was added without focus
containerCtrl && containerCtrl.setFocused(!!ngModelCtrl.$modelValue && containerCtrl.element.hasClass('md-input-focused'));
}

function findSelectContainer() {
selectContainer = angular.element(
element[0].querySelector('.md-select-menu-container')
Expand Down

0 comments on commit e49951c

Please sign in to comment.