From 9d0638c40f9c883be4d0a72ac5856717687b150d Mon Sep 17 00:00:00 2001 From: Ahtsham Raziq Date: Fri, 20 Oct 2017 17:37:13 +0500 Subject: [PATCH] fix(typeahead): select active match on TAB (#2839) --- src/typeahead/typeahead.directive.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/typeahead/typeahead.directive.ts b/src/typeahead/typeahead.directive.ts index 3e7398ad99..769ca082a9 100644 --- a/src/typeahead/typeahead.directive.ts +++ b/src/typeahead/typeahead.directive.ts @@ -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; @@ -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 {