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

Commit 13c14af

Browse files
committed
fix(typeahead): change to select class
- Change to select `.uib-typeahead-match` class instead of the `li` tag BREAKING CHANGE: This changes the selector used so that it doesn't select for the `li` tag specifically, but the elements with the class `uib-typeahead-match` - if using a custom template, this class needs to be added to the `li` element in the typeahead popup template. Closes #5922 Fixes #5848
1 parent 280ddaf commit 13c14af

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

src/typeahead/docs/readme.md

+4
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,7 @@ This directive works with promises, meaning you can retrieve matches using the `
120120
<small class="badge">$</small>
121121
<i class="glyphicon glyphicon-eye-open"></i> -
122122
Comprehension Angular expression (see [select directive](http://docs.angularjs.org/api/ng.directive:select)).
123+
124+
**Notes**
125+
126+
If a custom template for the popup is used, the wrapper selector used for the match items is the `uib-typeahead-match` class.

src/typeahead/typeahead.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -402,13 +402,13 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.debounce', 'ui.bootstrap
402402
case 38: // up arrow
403403
scope.activeIdx = (scope.activeIdx > 0 ? scope.activeIdx : scope.matches.length) - 1;
404404
scope.$digest();
405-
target = popUpEl.find('li')[scope.activeIdx];
405+
target = popUpEl[0].querySelectorAll('.uib-typeahead-match')[scope.activeIdx];
406406
target.parentNode.scrollTop = target.offsetTop;
407407
break;
408408
case 40: // down arrow
409409
scope.activeIdx = (scope.activeIdx + 1) % scope.matches.length;
410410
scope.$digest();
411-
target = popUpEl.find('li')[scope.activeIdx];
411+
target = popUpEl[0].querySelectorAll('.uib-typeahead-match')[scope.activeIdx];
412412
target.parentNode.scrollTop = target.offsetTop;
413413
break;
414414
default:
+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'}" role="listbox" aria-hidden="{{!isOpen()}}">
2-
<li ng-repeat="match in matches track by $index" ng-class="{active: isActive($index) }" ng-mouseenter="selectActive($index)" ng-click="selectMatch($index, $event)" role="option" id="{{::match.id}}">
2+
<li class="uib-typeahead-match" ng-repeat="match in matches track by $index" ng-class="{active: isActive($index) }" ng-mouseenter="selectActive($index)" ng-click="selectMatch($index, $event)" role="option" id="{{::match.id}}">
33
<div uib-typeahead-match index="$index" match="match" query="query" template-url="templateUrl"></div>
44
</li>
55
</ul>

0 commit comments

Comments
 (0)