Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

md-on-select not called when deleting tabs #2730

Closed
jo-me opened this issue May 5, 2015 · 5 comments
Closed

md-on-select not called when deleting tabs #2730

jo-me opened this issue May 5, 2015 · 5 comments
Assignees
Milestone

Comments

@jo-me
Copy link

jo-me commented May 5, 2015

According to the docs the md-on-select should be called "after the tab has been selected".
However, this fails to work when you remove tabs.

This becomes apparent in the dynamic tabs demo on
https://material.angularjs.org/#/demo/material.components.tabs

If you have an open chrome console when you switch tabs you can see logs like:
Goodbye Two!
Hello Eight!
Goodbye Eight!

If you select e.g. tab page 3 and delete it there is no such output afterwards even though tab 4 is now selected.

It only works if you open the very last tab and delete it:
Hello Ten!
now click delete
Goodbye Ten!
Hello Nine!

@jo-me
Copy link
Author

jo-me commented May 5, 2015

I realize that the log output does not come from md-on-select, but the behavior is the same for me.

@jo-me
Copy link
Author

jo-me commented May 5, 2015

Ok, I created a plnkr:
http://plnkr.co/edit/DorMcJAmkuFpVG6wTBaj?p=preview

Either open the chrome console or look at the "Last Log:" line at the bottom which is updated by the function defined in the md-on-select declaration.

There, the second issue I experienced also becomes visible:
The very first md-on-select event is never fired! This was the case in 0.8.3, though.

If you like I can create a 2nd issue for that.

@gio82
Copy link

gio82 commented May 13, 2015

+1

@jjf1
Copy link

jjf1 commented May 22, 2015

Not exactly the same, but was having problems with mdTabs after 1) removing some tabs, 2) closing the mdTabs element, 3) reopening the mdTabs element with some newly reattached tabs.

Had to go into mdTabs directive to fix. The scope must be explicitly deleted when mdTabs element is destroyed, or when a new MdTabsController spins up, BOTH the new and old controllers are watching/manipulating the same data, causing any number of defective behaviors.

Here is what was added...

function MdTabs ($mdTheming, $mdUtil, $compile) {
return {
scope: {
noPagination: '=?mdNoPagination',
dynamicHeight: '=?mdDynamicHeight',
centerTabs: '=?mdCenterTabs',
selectedIndex: '=?mdSelected',
stretchTabs: '@?mdStretchTabs'
},
.
.
.
controller: 'MdTabsController',
controllerAs: '$mdTabsCtrl',
link: function (scope, element, attr) {

  element.on('$destroy', function () { 
    scope.$destroy();
  });

@robertmesserle
Copy link
Contributor

Should be resolved by 5e47b52

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

No branches or pull requests

5 participants