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

Tab select method fired during scope destruction if used in Modal Directive #3366

Closed
mu7amed-abdelfata7 opened this issue Mar 7, 2015 · 2 comments

Comments

@mu7amed-abdelfata7
Copy link

I used Tabs in Modal ..when modal close or dismiss, then trigger the tabselected, here is the plunkr:
http://plnkr.co/edit/0pcQYD5ESgQC0COYsObZ?p=preview

The problem is still remaining and did not fix as you discussed in:
#2155

But i made a solution for me to solve the problem:
1- I added this function in TabsetController:

var destroyed = false;
ctrl.destroyTab = function destroyTab(tab) {
console.info("ctrl.destroyTab = function destroyTab(tab) {");
destroyed = true;
ctrl.removeTab(tab);
};

2-I calling destroyTab() rather than removeTab() in $on('$destroy') in tab directive:
scope.$on('$destroy', function() {
tabsetCtrl.destroyTab(scope);
});

here is the plunker of the solution:
http://plnkr.co/edit/weXJbOWP5okQuqd3EVRS?p=preview
see the ui-bootstrap-tpls-0.12.1-updated.js file in the plunker

please see if this solution is proper for the directive or not.

@chrisirhc
Copy link
Contributor

Thanks for the reproduction. You're right #2155 isn't fixed.

The fix was incomplete as the child scope's $destroy handlers are fired before its parent's $destroy handlers. So removeTab was still being called before destroy is set to true. My fix was also missing tests, so that was just bad heh.

@wesleycho
Copy link
Contributor

Not seeing this anymore here, I'm assuming this has now been fixed.

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

4 participants