ykoehler
11 Jun 2010, 6:45 AM
If you aren't destroying an object when removing it from a panel it won't be removed from the DOM, meaning that it won't be in the parent container's items list anymore but will still be visible on the screen as if it was still in the parent container.
Code to reproduce the bug:
Ext.onReady(function() {
Ext.BLANK_IMAGE_URL = 'images/s.gif';
var panel1 = new Ext.Panel({
id: 'panel1',
title: 'Panel 1'
});
var panel2 = new Ext.Panel({
id: 'panel2',
title: 'Panel 2'
});
var viewportBodyPanel = new Ext.Panel({
id: 'viewportBodyPanel'
});
var viewport = new Ext.Viewport({
layout: 'fit',
items: viewportBodyPanel
});
viewportBodyPanel.add(panel1);
viewportBodyPanel.doLayout();
viewportBodyPanel.removeAll(false);
viewportBodyPanel.add(panel2);
viewportBodyPanel.doLayout();
/* Expectation is that panel2 is now visible and panel1 isn't anymore yet remains a valid panel
that may later be added elsewhere. */
});
Code to fix the bug:
Ext.Panel.override ({
remove: function(comp, autoDestroy) {
if(this.rendered){
comp.removeFromDOM();
this.rendered = false;
}
Ext.Panel.superclass.remove.call(this, comp, autoDestroy);
},
removeFromDOM: function() {
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
);
}
}
});
--
Yannick Koehler
Code to reproduce the bug:
Ext.onReady(function() {
Ext.BLANK_IMAGE_URL = 'images/s.gif';
var panel1 = new Ext.Panel({
id: 'panel1',
title: 'Panel 1'
});
var panel2 = new Ext.Panel({
id: 'panel2',
title: 'Panel 2'
});
var viewportBodyPanel = new Ext.Panel({
id: 'viewportBodyPanel'
});
var viewport = new Ext.Viewport({
layout: 'fit',
items: viewportBodyPanel
});
viewportBodyPanel.add(panel1);
viewportBodyPanel.doLayout();
viewportBodyPanel.removeAll(false);
viewportBodyPanel.add(panel2);
viewportBodyPanel.doLayout();
/* Expectation is that panel2 is now visible and panel1 isn't anymore yet remains a valid panel
that may later be added elsewhere. */
});
Code to fix the bug:
Ext.Panel.override ({
remove: function(comp, autoDestroy) {
if(this.rendered){
comp.removeFromDOM();
this.rendered = false;
}
Ext.Panel.superclass.remove.call(this, comp, autoDestroy);
},
removeFromDOM: function() {
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
);
}
}
});
--
Yannick Koehler