Commit 620543d7 authored by Bas Lijnse's avatar Bas Lijnse

Fixed selection of new active tab when current active tab is removed

parent 33af83af
Pipeline #29095 failed with stage
in 1 minute and 13 seconds
......@@ -242,6 +242,7 @@ itasks.TabSet = {
}
me.activeTab = idx || 0;
//Select new tab
if(me.children[me.activeTab]) {
me.children[me.activeTab].domEl.classList.add(me.cssPrefix + 'selected');
......@@ -290,14 +291,20 @@ itasks.TabSet = {
me.setActiveTabBasedOnOrder();
}
},
beforeChildRemove: function(idx) {
afterChildRemove: function(idx) {
var me = this;
if(me.initialized) {
if(!me.replacing && (idx == me.activeTab) && (me.children.length > 1)) { //Unless we remove the last tab, select another tab
delete me.children[idx].attributes["order"];
if(me.initialized && !me.replacing) {
me.tabBar.removeChild(me.tabBar.children[idx]);
//If we removed the currently active tab, we need to select another one
if(idx == me.activeTab) {
me.setActiveTabBasedOnOrder();
} else if(idx < me.activeTab) {
//When a tab before the active tab is removed, it implies that the active index
//is now one less
me.activeTab--;
}
me.tabBar.removeChild(me.tabBar.children[idx]);
}
},
afterChildChange: function(idx,change) {
......
......@@ -234,6 +234,7 @@ itasks.Component = {
me.containerEl.removeChild(me.containerEl.childNodes[idx]);
}
me.children.splice(idx,1);
me.afterChildRemove(idx);
},
replaceChild: function(idx,spec) {
var me = this;
......@@ -257,6 +258,7 @@ itasks.Component = {
me.children.splice(didx, 0, child);
},
beforeChildRemove: function(idx,child) {},
afterChildRemove: function(idx) {},
/* beforeRemove can be overwritten to add a handler for 'destroy' events.
* _beforeRemove is internal and should not be overwritten.
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment