Skip to content

Commit

Permalink
Merge pull request valor-software#360 from fkowal/fix_typeahead_submi…
Browse files Browse the repository at this point in the history
…t_form

prevent submiting of form when typeahead container is visible
  • Loading branch information
valorkin committed Apr 1, 2016
2 parents 519be28 + 4297410 commit 232b8ae
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 232b8ae

Please sign in to comment.