Skip to content

Commit

Permalink
fix(typeahead): select active match on TAB (#2839)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahtsham Raziq authored and valorkin committed Oct 20, 2017
1 parent 033f6e3 commit 9d0638c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/typeahead/typeahead.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ export class TypeaheadDirective implements OnInit, OnDestroy {
return;
}

// enter
if (e.keyCode === 13) {
// enter, tab
if (e.keyCode === 13 || e.keyCode === 9) {
this._container.selectActiveMatch();

return;
Expand Down Expand Up @@ -249,12 +249,19 @@ export class TypeaheadDirective implements OnInit, OnDestroy {
return;
}

// if items is visible - prevent form submition
// if an item is visible - prevent form submission
if (e.keyCode === 13) {
e.preventDefault();

return;
}

// if an item is visible - don't change focus
if (e.keyCode === 9) {
e.preventDefault();

return;
}
}

changeModel(match: TypeaheadMatch): void {
Expand Down

0 comments on commit 9d0638c

Please sign in to comment.