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

Commit

Permalink
fix(autocomplete): hitting Enter will now trigger the submit method o…
Browse files Browse the repository at this point in the history
…n parent form tags

Closes #1530.
  • Loading branch information
Robert Messerle committed Feb 17, 2015
1 parent c9dd626 commit da084fc
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions src/components/autocomplete/js/autocompleteController.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,36 +94,36 @@
function keydown (event) {
switch (event.keyCode) {
case $mdConstant.KEY_CODE.DOWN_ARROW:
if (self.loading) return;
event.preventDefault();
self.index = Math.min(self.index + 1, self.matches.length - 1);
updateScroll();
break;
if (self.loading) return;
event.preventDefault();
self.index = Math.min(self.index + 1, self.matches.length - 1);
updateScroll();
break;
case $mdConstant.KEY_CODE.UP_ARROW:
if (self.loading) return;
event.preventDefault();
self.index = Math.max(0, self.index - 1);
updateScroll();
break;
if (self.loading) return;
event.preventDefault();
self.index = Math.max(0, self.index - 1);
updateScroll();
break;
case $mdConstant.KEY_CODE.ENTER:
if (self.loading) return;
event.preventDefault();
select(self.index);
break;
if (self.loading || self.index < 0) return;
event.preventDefault();
select(self.index);
break;
case $mdConstant.KEY_CODE.ESCAPE:
self.matches = [];
self.hidden = true;
self.index = -1;
break;
self.matches = [];
self.hidden = true;
self.index = -1;
break;
case $mdConstant.KEY_CODE.TAB:
break;
break;
default:
self.index = -1;
self.hidden = isHidden();
//-- after value updates, check if list should be hidden
$timeout(function () {
self.index = -1;
self.hidden = isHidden();
});
//-- after value updates, check if list should be hidden
$timeout(function () {
self.hidden = isHidden();
});
}
}

Expand Down

0 comments on commit da084fc

Please sign in to comment.