PDA

View Full Version : [FIXED-414][3.1] Bug with hidden button ?



keyra
8 Jan 2010, 1:18 PM
Hi All,

I'm working with ExtJS 3.1 since some weeks ago and I have found an error during my development. Here is a sample code with the issue:


var userForm = new Ext.FormPanel({
items:
[{
xtype: 'textfield',
fieldLabel: 'Test'
}],
buttons:
[{
text: 'add'
},
{
text: 'cancel',
hidden: true
}]
});

new Ext.Window({
layout:'fit',
width:300,
height:100,
closable: true,
items: [userForm],
title: 'Add'
}).show();

The issue occurs when the window is closed: "this.dom is undefined".
The ExtJS source code involved is:


isBorderBox : function(){
return noBoxAdjust[(this.dom.tagName || "").toLowerCase()] || Ext.isBorderBox;
},

After some testing, it seems that the issue is linked to the options layout: fit and the hidden button. Note that if we remove the first button (which is displayed), the error is not raised.

As I'm a new width extjs, I would like to know if the issue is normal or if it is really a bug ?

Thanks in advance for your answer.

K.

brentdooley999
13 Jan 2010, 7:54 AM
After a couple of hours of debugging I worked my problem back to this same issue. I was about to report it as a bug but did a quick search and here it is.

I'm having the same problem. If I create a panel that is a child of another panel and add a few buttons, if the LAST button is hidden when the child is removed from the parent using


Ext.getCmp('<parent_id>').remove(Ext.getCmp('<child_id>'), true);

I get the same "this.dom is undefined" error.

I'm pretty sure this worked in 3.0.3.

If you need me to throw together a test case or try it in 3.0.3 please let me know.

-brent

brentdooley999
13 Jan 2010, 7:56 AM
Ok, I went ahead and checked and it works fine in 3.0.3.

-brent

Condor
13 Jan 2010, 8:16 AM
We should probably add:

Ext.override(Ext.Panel, {
beforeDestroy : function(){
Ext.Panel.superclass.beforeDestroy.call(this);
if(this.header){
this.header.removeAllListeners();
}
if(this.tools){
for(var k in this.tools){
Ext.destroy(this.tools[k]);
}
}
if(this.toolbars.length > 0){
Ext.each(this.toolbars, function(tb){
tb.un('afterlayout', this.syncHeight, this);
tb.un('remove', this.syncHeight, this);
}, this);
}
if(Ext.isArray(this.buttons)){
while(this.buttons.length) {
Ext.destroy(this.buttons[0]);
}
}
if(this.rendered){
Ext.destroy(
this.ft,
this.header,
this.footer,
this.toolbars,
this.tbar,
this.bbar,
this.body,
this.mc,
this.bwrap
);
if (this.fbar) {
Ext.destroy(
this.fbar,
this.fbar.el
);
}
}else{
Ext.destroy(
this.topToolbar,
this.bottomToolbar
);
}
}
});
(also speeds up the destroy process)

Jamie Avins
13 Jan 2010, 4:10 PM
Thank you for the concise test case and Condor for the correct fix.

Fixed in SVN 5875.

papandreou
15 Jan 2010, 1:13 AM
Fixed in SVN 5875.

Sounds great. Will the fix be backported to the 3.1.x branch?

Best regards,
Papandreou

Jamie Avins
15 Jan 2010, 10:16 AM
This will be in the 3.1.1 patch relese. There is a beta that will be posted to the forums today.

http://www.extjs.com/forum/showthread.php?t=89148