Skip to content

Commit

Permalink
fix(typeahead): prevent form submition when typeahead selected (fixes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
Maciej Kowalski committed Apr 1, 2016
1 parent 4220780 commit 4297410
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions components/typeahead/typeahead.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,14 @@ export class Typeahead implements OnInit {
}
}

@HostListener('keydown', ['$event'])
onKeydown(e:KeyboardEvent) {
// When typeahead container is visible, prevent submitting the form
if (this.container && e.keyCode === 13) {
e.preventDefault();
}
}

@HostListener('keyup', ['$event'])
onChange(e:KeyboardEvent) {
if (this.container) {
Expand Down

0 comments on commit 4297410

Please sign in to comment.