PDA

View Full Version : [DUP][CLOSED][3.x] TabPanel.getActiveTab() returns string for unrendered active tab



papandreou
31 Aug 2009, 6:39 AM
Hi!

Upgrading to r5217 caused a javascript error in an application I'm working on. I was expecting TabPanel.getActiveTab() to return a panel or null if the tab hadn't been rendered yet, as per the documentation. It turns out that in the latter case the string id of the active tab is returned, but only if the activeTab config option was given as a string. The activeTab option also supports numerical indices, but in that case null is returned as expected.

I guess that behavior could be useful in some cases, but then it really should be documented.

The below test case demonstrates the issue. (I'm aware that it doesn't sense to expect the tab to be rendered when the TabPanel's render event is fired, but it's an easy way to demonstrate that getActiveTab() can return a string).



Ext.onReady(function() {
new Ext.Viewport({
items: {
xtype: 'tabpanel',
activeTab: 'foo',
listeners: {
render: function(tabPanel) {
var activeTab = tabPanel.getActiveTab();
if (activeTab) { // Needs to be activeTab && typeof activeTab !== 'string'
//activeTab.setTitle("hello"); // Would fail here because activeTab is a string!
alert("activeTab = ", activeTab);
}
}
},
items: [
{
xtype: 'panel',
id: 'foo'
}
]
}
});
});
Best regards,
Papandreou

evant
5 Oct 2009, 8:20 PM
Going to close this thread, since we have another of the same here: http://www.extjs.com/forum/showthread.php?t=81922