Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit a1355e7

Browse files
dgermekwesleycho
authored andcommitted
feat(typeahead): add ability to scroll with matches
- This adds scrolling capability with matches when using keyboard navigation Closes #4463
1 parent ef82ad1 commit a1355e7

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/typeahead/typeahead.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -368,9 +368,11 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position'])
368368
if (evt.which === 40) {
369369
scope.activeIdx = (scope.activeIdx + 1) % scope.matches.length;
370370
scope.$digest();
371+
popUpEl.children()[scope.activeIdx].scrollIntoView(false);
371372
} else if (evt.which === 38) {
372373
scope.activeIdx = (scope.activeIdx > 0 ? scope.activeIdx : scope.matches.length) - 1;
373374
scope.$digest();
375+
popUpEl.children()[scope.activeIdx].scrollIntoView(false);
374376
} else if (evt.which === 13 || evt.which === 9) {
375377
scope.$apply(function () {
376378
scope.select(scope.activeIdx);
@@ -570,7 +572,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position'])
570572
};
571573
}])
572574

573-
.filter('uibTypeaheadHighlight', ['$sce', '$injector', '$log', function($sce, $injector, $log) {
575+
.filter('typeaheadHighlight', ['$sce', '$injector', '$log', function($sce, $injector, $log) {
574576
var isSanitizePresent;
575577
isSanitizePresent = $injector.has('$sanitize');
576578

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<ul class="dropdown-menu" ng-show="isOpen() && !moveInProgress" ng-style="{top: position().top+'px', left: position().left+'px'}" style="display: block;" role="listbox" aria-hidden="{{!isOpen()}}">
22
<li ng-repeat="match in matches track by $index" ng-class="{active: isActive($index) }" ng-mouseenter="selectActive($index)" ng-click="selectMatch($index)" role="option" id="{{::match.id}}">
3-
<div uib-typeahead-match index="$index" match="match" query="query" template-url="templateUrl"></div>
3+
<div typeahead-match index="$index" match="match" query="query" template-url="templateUrl"></div>
44
</li>
55
</ul>

0 commit comments

Comments
 (0)