Bug: Typeahead broken in latest angular
Seems Typeahead isn't working correctly since v1.3.0-build.2783.
Keyboard jumps through the items, but it doesn't highlight them, so you can't see which one is selected. Clicking with the mouse on the typeahead list doesn't update the input.
These bugs show up in Chrome and Safari, haven't tried any other browsers.
http://plnkr.co/edit/poA6Pu?p=preview
Indeed, this sounds like a regression on the AngularJS side.... Not sure what could have caused this atm, though.
I'm not seeing the popup's methods being called
Just ran into this too
+1 it was working fine till 1.3.0-beta.5.
Looks like this actually broke in v1.3.0-beta.11. It appears to be working in v1.3.0-beta.10
@caitp just looking into this, but I'm not 100% sure which exact commit broke this :-/
It's likely related to Pete/Vojta's transclusion fixes, @pkozlowski-opensource --- but I think we don't want to revert those changes
@caitp - presumably those fixes relate AngularJS 5489 amongst others?
On the basis any changes like this to transclusion are likely to have wider reaching impact, is there a document somewhere that captures the scope and impact of said changes? I suspect typeahead won't be the only place affected.
Any simple workaround other than dropping back to an older version of angular?
AngularJS #8072 appears to confirm the bug is within angular-ui. However I can't make the solution proposed by @wazzeb work against AngularJS master.
setting typeahead-template-url also appears to be broken in Angular 1.3.0-beta14.
I've submitted #2535 as a fix for this. I've confirmed that this does fix the issue with 1.3.0-beta.17. Simple change, but it works just fine.
@kkragenbrink Just tried that out. Works great on Chrome, Safari, IOS & Android.
Who would have thought it'd be that simple! Thanks.
+1
Use decorator to extend third party directives, so that if they are upgrading you can upgrade your lib without code change, just you can remove your decorator.
<!DOCTYPE html>
<html>
<head>
<title>Adding/modifying predefined Services/Direcives</title>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.1/angular.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.12.1/ui-bootstrap-tpls.js"></script>
<link rel="stylesheet" type="text/css" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<script>
'''javascript
window.onload = function() { //After loading scripts
var decoApp = angular.module('decoApp', ['ui.bootstrap']);
decoApp.run(['$rootScope',
function(r) {
r.states = [];
for (var a = 1000; a > 0; a--) {
r.states.push({
name: "state" + a,
id: a
});
}
}
]);
decoApp.config(function($provide) {
$provide.decorator('typeaheadDirective', function($delegate) {
//console.log($delegate);
var directive = $delegate[0];
var link = directive.link;
var keyCodes = {
37: 'left',
39: 'right',
38: 'up',
40: 'down'
};
directive.compile = function() {
console.log('compiling');
return function(scope, element, attrs) {
console.log(element, attrs);
link.apply(this, arguments);
setTimeout(function() { //time delay to render the directive by angular
var dropdownId = element[0].attributes.getNamedItem('aria-owns').value;
var dropdownElement = angular.element(document.getElementById(dropdownId));
dropdownElement.css('height', '200px');
dropdownElement.css('overflow-y', 'scroll');
//bind event
element.on('keydown', function(e) {
if (!!keyCodes[event.keyCode]) {
if (e.target.attributes.getNamedItem('aria-owns').value === dropdownId) {
var activeItemId = e.target.attributes.getNamedItem('aria-activedescendant').value;
var top = document.getElementById(activeItemId).offsetTop;
dropdownElement[0].scrollTop = top;
}
}
});
//unbind event
var destroyEvent = scope.$on('$destroy', function() {
console.log('$destroy');
if (typeof destroyEvent === 'function') {
destroyEvent();
}
element.off('keydown');
});
}, 2000);
};
};
return $delegate;
});
});
angular.bootstrap(document, ['decoApp']);
}
'''
</script>
</head>
<body>
<div class="form-group">
<label>Type a number</label>
<input class="form-control" type="text" ng-model="selected" typeahead="state.name for state in $root.states | filter:$viewValue | limitTo:28" class="form-control">
</div>
</body>
</html>
I'm still having the same type-ahead problems with 1.4.5. Has this problem now been confirmed solved?
I am also facing the same problem. Using Bootstrap 0.11.0 and angular js 1.4.8.
@ashigl, please do not comment on closed issues. doing so is a really good way for them to be missed or ignored.
I am also facing the same problem. Using Bootstrap v3.3.6 and angular js v1.4.7