I created a small 'fix' for the Ext.tab.Panel
. I hope this helps you.
Update
- Works like expected now :)
- The badgeCls cant have an array as parameter (If you want this functionality let me know ;))
Override:
Ext.define('My.tab.Panel', {
override: 'Ext.tab.Panel',
onItemAdd: function(card) {
var me = this;
if (!card.isInnerItem()) {
return me.callParent(arguments);
}
var tabBar = me.getTabBar(),
initialConfig = card.getInitialConfig(),
tabConfig = initialConfig.tab || {},
tabTitle = (card.getTitle) ? card.getTitle() : initialConfig.title,
tabIconCls = (card.getIconCls) ? card.getIconCls() : initialConfig.iconCls,
tabHidden = (card.getHidden) ? card.getHidden() : initialConfig.hidden,
tabDisabled = (card.getDisabled) ? card.getDisabled() : initialConfig.disabled,
tabBadgeText = (card.getBadgeText) ? card.getBadgeText() : initialConfig.badgeText,
tabBadgeCls = (card.getBadgeCls) ? card.getBadgeCls() : initialConfig.badgeCls,
innerItems = me.getInnerItems(),
index = innerItems.indexOf(card),
tabs = tabBar.getItems(),
activeTab = tabBar.getActiveTab(),
currentTabInstance = (tabs.length >= innerItems.length) && tabs.getAt(index),
tabInstance;
if (tabTitle && !tabConfig.title) {
tabConfig.title = tabTitle;
}
if (tabIconCls && !tabConfig.iconCls) {
tabConfig.iconCls = tabIconCls;
}
if (tabHidden && !tabConfig.hidden) {
tabConfig.hidden = tabHidden;
}
if (tabDisabled && !tabConfig.disabled) {
tabConfig.disabled = tabDisabled;
}
if (tabBadgeText && !tabConfig.badgeText) {
tabConfig.badgeText = tabBadgeText;
}
if (tabBadgeCls && !tabConfig.badgeCls) {
tabConfig.badgeCls = Ext.baseCSSPrefix + 'badge ' + tabBadgeCls;
}
//<debug warn>
if (!currentTabInstance && !tabConfig.title && !tabConfig.iconCls) {
if (!tabConfig.title && !tabConfig.iconCls) {
Ext.Logger.error('Adding a card to a tab container without specifying any tab configuration');
}
}
//</debug>
tabInstance = Ext.factory(tabConfig, Ext.tab.Tab, currentTabInstance);
if (!currentTabInstance) {
tabBar.insert(index, tabInstance);
}
card.tab = tabInstance;
me.callParent(arguments);
if (!activeTab && activeTab !== 0) {
tabBar.setActiveTab(tabBar.getActiveItem());
}
}
});
Ext.tab.Panel
. This configuration is for buttons only but I understand you expect it to work for a tabpanel too! – A1rPun