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

Bug: Typeahead broken in latest angular #2293

Closed
noducks opened this issue Jun 3, 2014 · 19 comments
Closed

Bug: Typeahead broken in latest angular #2293

noducks opened this issue Jun 3, 2014 · 19 comments

Comments

@noducks
Copy link

noducks commented Jun 3, 2014

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

@pkozlowski-opensource
Copy link
Member

Indeed, this sounds like a regression on the AngularJS side.... Not sure what could have caused this atm, though.

@caitp
Copy link
Contributor

caitp commented Jun 4, 2014

I'm not seeing the popup's methods being called

@myitcv
Copy link

myitcv commented Jun 10, 2014

Just ran into this too

@xmlking
Copy link

xmlking commented Jun 14, 2014

+1
it was working fine till 1.3.0-beta.5.

@myitcv
Copy link

myitcv commented Jun 17, 2014

Looks like this actually broke in v1.3.0-beta.11. It appears to be working in v1.3.0-beta.10

@pkozlowski-opensource
Copy link
Member

@caitp just looking into this, but I'm not 100% sure which exact commit broke this :-/

@caitp
Copy link
Contributor

caitp commented Jun 18, 2014

It's likely related to Pete/Vojta's transclusion fixes, @pkozlowski-opensource --- but I think we don't want to revert those changes

@myitcv
Copy link

myitcv commented Jun 18, 2014

@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.

@davisford
Copy link

Any simple workaround other than dropping back to an older version of angular?

@myitcv
Copy link

myitcv commented Jul 10, 2014

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.

@joshbowdoin
Copy link

setting typeahead-template-url also appears to be broken in Angular 1.3.0-beta14.

@nivthefox
Copy link

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.

@noducks
Copy link
Author

noducks commented Aug 1, 2014

@kkragenbrink Just tried that out. Works great on Chrome, Safari, IOS & Android.

Who would have thought it'd be that simple! Thanks.

@futurechan
Copy link

+1

@9442552055
Copy link

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>

@jonathanmclarke-zz
Copy link

I'm still having the same type-ahead problems with 1.4.5. Has this problem now been confirmed solved?

@ashigl
Copy link

ashigl commented Jan 15, 2016

I am also facing the same problem. Using Bootstrap 0.11.0 and angular js 1.4.8.

@icfantv
Copy link
Contributor

icfantv commented Jan 15, 2016

@ashigl, please do not comment on closed issues. doing so is a really good way for them to be missed or ignored.

@cscuser
Copy link

cscuser commented Jul 27, 2017

I am also facing the same problem. Using Bootstrap v3.3.6 and angular js v1.4.7

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests