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

Typeahead is-open via document click does not trigger if transcluded #6060

Open
hansmaad opened this issue Jun 29, 2016 · 2 comments
Open

Typeahead is-open via document click does not trigger if transcluded #6060

hansmaad opened this issue Jun 29, 2016 · 2 comments

Comments

@hansmaad
Copy link

Bug description:

This is related to this (fixed) issue: #5467

In dismissClickHandler we have to call originalScope.$digest() to update the is-open binding. But if the typeahead directive is transcluded, originalScope is the transcluded scope.

I tried to change the handler to use (originalScope.$$transcluded ? originalScope.$parent : originalScope).$digest(); and it works. originalScope.$apply() seems to work too. But I don't know if this makes sense.

Link to minimally-working plunker that reproduces the issue:

http://plnkr.co/edit/QGt0h0mUz25QI4LcjZ4K?p=preview

Version of Angular, UIBS, and Bootstrap

<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.js"></script>
<script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-1.3.3.js"></script>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
@wesleycho
Copy link
Contributor

I think one would have to create a function to recursively walk up the $scope tree, since presumably originalScope.$parent.$$transcluded could be true as well.

I would be open to a PR for this.

@hansmaad
Copy link
Author

hansmaad commented Jun 30, 2016

@wesleycho Do you think we could do a while(originalScope.$$transcluded) originalScope = originalScope.$parent; right at the beginning? It doesn't break any unit test and fixes this issue.
I've written a unit test for this and could prepeare a PR.

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

2 participants