Animal
15 Dec 2009, 4:02 AM
Setting the active item in a CardLayout calls doLayout to ensure that the item being activated is fully rendered.
The trouble with the way TabPanel activates its configured active tab now, is that it does this during the rendering process.
Laying out must happen only in response to a doLayout call, not once during the rendering process, and then again when the doLayout call is made to actually render the Viewport or Window, or whatever it is that contains the TabPanel.
The fix is to set the active item on layout:
Ext.override(Ext.TabPanel, {
afterRender : function(){
Ext.TabPanel.superclass.afterRender.call(this);
if(this.autoTabs){
this.readTabs(false);
}
},
onLayout: function() {
Ext.TabPanel.superclass.onLayout.call(this);
// On first layout (The activeTab property still present), activate it.
if(this.activeTab !== undefined){
var item = Ext.isObject(this.activeTab) ? this.activeTab : this.items.get(this.activeTab);
delete this.activeTab;
this.setActiveTab(item);
}
}
});
The trouble with the way TabPanel activates its configured active tab now, is that it does this during the rendering process.
Laying out must happen only in response to a doLayout call, not once during the rendering process, and then again when the doLayout call is made to actually render the Viewport or Window, or whatever it is that contains the TabPanel.
The fix is to set the active item on layout:
Ext.override(Ext.TabPanel, {
afterRender : function(){
Ext.TabPanel.superclass.afterRender.call(this);
if(this.autoTabs){
this.readTabs(false);
}
},
onLayout: function() {
Ext.TabPanel.superclass.onLayout.call(this);
// On first layout (The activeTab property still present), activate it.
if(this.activeTab !== undefined){
var item = Ext.isObject(this.activeTab) ? this.activeTab : this.items.get(this.activeTab);
delete this.activeTab;
this.setActiveTab(item);
}
}
});