material icon indicating copy to clipboard operation
material copied to clipboard

md-on-select not called when deleting tabs

Open jo-me opened this issue 11 years ago • 5 comments

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 avatar May 05 '15 17:05 jo-me

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

jo-me avatar May 05 '15 17:05 jo-me

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.

jo-me avatar May 05 '15 18:05 jo-me

+1

gio82 avatar May 13 '15 08:05 gio82

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();
  });

jjf1 avatar May 22 '15 18:05 jjf1

Should be resolved by 5e47b52bd6a8817b2624ca6797b8267a162f84af

robertmesserle avatar May 30 '15 01:05 robertmesserle