From a7b9f0edcb7276e485c637cdb797cd4dbf6bebf3 Mon Sep 17 00:00:00 2001 From: dsisejkovic Date: Thu, 24 Sep 2015 12:02:02 +0200 Subject: [PATCH 1/3] Enabled typeahead popup scroll --- src/typeahead/typeahead.js | 13 +++++++++++++ template/typeahead/typeahead-popup.html | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/typeahead/typeahead.js b/src/typeahead/typeahead.js index fd19ed1632..d0eae2885e 100644 --- a/src/typeahead/typeahead.js +++ b/src/typeahead/typeahead.js @@ -499,6 +499,19 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position']) }; }]) + .directive('focusMe', function(){ + return { + restrict: 'A', + link: function(scope,element,attrs){ + scope.$watch(attrs.shouldFocus,function(newValue,oldValue){ + if (newValue) { + element[0].scrollIntoView(false); + } + }); + } + }; + }) + .filter('typeaheadHighlight', ['$sce', '$injector', '$log', function($sce, $injector, $log) { var isSanitizePresent; isSanitizePresent = $injector.has('$sanitize'); diff --git a/template/typeahead/typeahead-popup.html b/template/typeahead/typeahead-popup.html index 43693ac35e..bfb4b5dd4d 100644 --- a/template/typeahead/typeahead-popup.html +++ b/template/typeahead/typeahead-popup.html @@ -1,5 +1,5 @@ From dd85a613a004f7ed7e0814e7638d12a3be332443 Mon Sep 17 00:00:00 2001 From: dsisejkovic Date: Thu, 24 Sep 2015 18:25:08 +0200 Subject: [PATCH 2/3] changed directive name to shouldFocus --- src/typeahead/typeahead.js | 2 +- template/typeahead/typeahead-popup.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/typeahead/typeahead.js b/src/typeahead/typeahead.js index d0eae2885e..cb489a3c42 100644 --- a/src/typeahead/typeahead.js +++ b/src/typeahead/typeahead.js @@ -499,7 +499,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position']) }; }]) - .directive('focusMe', function(){ + .directive('shouldFocus', function(){ return { restrict: 'A', link: function(scope,element,attrs){ diff --git a/template/typeahead/typeahead-popup.html b/template/typeahead/typeahead-popup.html index bfb4b5dd4d..94f8bbed8f 100644 --- a/template/typeahead/typeahead-popup.html +++ b/template/typeahead/typeahead-popup.html @@ -1,5 +1,5 @@ From 5a90914b35c0f949f3a5e05368bfeaf27807e99b Mon Sep 17 00:00:00 2001 From: dsisejkovic Date: Thu, 29 Oct 2015 22:17:55 +0100 Subject: [PATCH 3/3] Added scroll into view to typeahead keydown handler --- src/typeahead/typeahead.js | 16 ++-------------- template/typeahead/typeahead-popup.html | 2 +- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/src/typeahead/typeahead.js b/src/typeahead/typeahead.js index cb489a3c42..4a64b489e5 100644 --- a/src/typeahead/typeahead.js +++ b/src/typeahead/typeahead.js @@ -379,7 +379,8 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position']) if (evt.which === 40) { scope.activeIdx = (scope.activeIdx + 1) % scope.matches.length; scope.$digest(); - + popUpEl.children()[scope.activeIdx].scrollIntoView(false); + } else if (evt.which === 38) { scope.activeIdx = (scope.activeIdx > 0 ? scope.activeIdx : scope.matches.length) - 1; scope.$digest(); @@ -499,19 +500,6 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position']) }; }]) - .directive('shouldFocus', function(){ - return { - restrict: 'A', - link: function(scope,element,attrs){ - scope.$watch(attrs.shouldFocus,function(newValue,oldValue){ - if (newValue) { - element[0].scrollIntoView(false); - } - }); - } - }; - }) - .filter('typeaheadHighlight', ['$sce', '$injector', '$log', function($sce, $injector, $log) { var isSanitizePresent; isSanitizePresent = $injector.has('$sanitize'); diff --git a/template/typeahead/typeahead-popup.html b/template/typeahead/typeahead-popup.html index 94f8bbed8f..43693ac35e 100644 --- a/template/typeahead/typeahead-popup.html +++ b/template/typeahead/typeahead-popup.html @@ -1,5 +1,5 @@