Skip to content

Commit

Permalink
fix: stopPropagation #17
Browse files Browse the repository at this point in the history
  • Loading branch information
skynet2 committed Dec 11, 2018
1 parent 1c42268 commit a106834
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/ngx-google-places-autocomplete.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,17 @@ export class GooglePlaceDirective implements AfterViewInit {
this.eventListener = this.autocomplete.addListener('place_changed', () => {
this.handleChangeEvent()
});

}

this.el.nativeElement.addEventListener('keydown', (event: KeyboardEvent) => {
let key = event.key.toLowerCase();

if (key == 'enter' && event.target === this.el.nativeElement) {
event.preventDefault();
event.stopPropagation();
}
});

// according to https://gist.github.com/schoenobates/ef578a02ac8ab6726487
if (window && window.navigator && window.navigator.userAgent && navigator.userAgent.match(/(iPad|iPhone|iPod)/g)) {
setTimeout(() => {
Expand All @@ -59,7 +67,7 @@ export class GooglePlaceDirective implements AfterViewInit {
if (!container)
continue;

container.addEventListener('touchend', function (e) {
container.addEventListener('touchend', (e) => {
e.stopImmediatePropagation();
});
}
Expand Down

0 comments on commit a106834

Please sign in to comment.