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

Commit

Permalink
feat(autocomplete): allows tab or enter to select an item
Browse files Browse the repository at this point in the history
Related to #2211
  • Loading branch information
Robert Messerle committed Apr 27, 2015
1 parent f66e471 commit 59015b0
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/components/autocomplete/js/autocompleteController.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,9 @@ function MdAutocompleteCtrl ($scope, $element, $mdUtil, $mdConstant, $timeout, $
updateScroll();
updateSelectionMessage();
break;
case $mdConstant.KEY_CODE.TAB:
case $mdConstant.KEY_CODE.ENTER:
if (self.hidden || self.loading || self.index < 0) return;
if (self.hidden || self.loading || self.index < 0 || self.matches.length < 1) return;
event.preventDefault();
select(self.index);
break;
Expand All @@ -249,8 +250,6 @@ function MdAutocompleteCtrl ($scope, $element, $mdUtil, $mdConstant, $timeout, $
self.hidden = true;
self.index = getDefaultIndex();
break;
case $mdConstant.KEY_CODE.TAB:
break;
default:
}
}
Expand Down

0 comments on commit 59015b0

Please sign in to comment.