Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
fix(select): focus should behave as same as normal inputs
Browse files Browse the repository at this point in the history
Fixes  #6122 Closes #6132
  • Loading branch information
devversion committed Dec 9, 2015
1 parent 190d304 commit 16ee9b9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
12 changes: 4 additions & 8 deletions src/components/select/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,6 @@ function SelectDirective($mdSelect, $mdUtil, $mdTheming, $mdAria, $compile, $par
return function postLink(scope, element, attr, ctrls) {
var isDisabled, ariaLabelBase;

// Remove event ngModel's blur listener for touched and untouched
// we will do it ourself.
$mdUtil.nextTick(function() {
element.off('blur');
});

var containerCtrl = ctrls[0];
var mdSelectCtrl = ctrls[1];
var ngModelCtrl = ctrls[2];
Expand Down Expand Up @@ -283,7 +277,8 @@ function SelectDirective($mdSelect, $mdUtil, $mdTheming, $mdAria, $compile, $par
containerCtrl.setFocused(true);
}
})
.on('blur', function(ev) {
.on('blur', function() {
if (selectScope.isOpen) return;
containerCtrl && containerCtrl.setFocused(false);
inputCheckValue();
});
Expand Down Expand Up @@ -466,6 +461,7 @@ function SelectDirective($mdSelect, $mdUtil, $mdTheming, $mdAria, $compile, $par
loadingAsync: attr.mdOnOpen ? scope.$eval(attr.mdOnOpen) || true : false
}).finally(function() {
selectScope.isOpen = false;
element.focus();
element.attr('aria-expanded', 'false');
ngModelCtrl.$setTouched();
});
Expand Down Expand Up @@ -1200,7 +1196,7 @@ function SelectProvider($$interimElementProvider) {
}
newOption = optionsArray[index];
if (newOption.hasAttribute('disabled')) newOption = undefined;
} while (!newOption && index < optionsArray.length - 1 && index > 0)
} while (!newOption && index < optionsArray.length - 1 && index > 0);
newOption && newOption.focus();
opts.focusedNode = newOption;
}
Expand Down
1 change: 0 additions & 1 deletion src/components/select/select.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,6 @@ describe('<md-select>', function() {
try {
el.triggerHandler('click');
waitForSelectOpen();
el.triggerHandler('blur');
} catch (e) { }
}

Expand Down

0 comments on commit 16ee9b9

Please sign in to comment.