PDA

View Full Version : [FIXED-489][3.0/2.2] Ext.Menu.addElement bug



jclawson
22 Oct 2008, 2:01 PM
I don't think the addElement function works as documented. addElement fails to move the DOM element into the menu list. This is because the menu item component is prematurely rendered in the instantiation of BaseItem.

When you call Ext.Menu.addElement, it creates a new BaseItem with that element as its argument. This constructs a new Ext.Component with this element as its argument. Ext.Component will call Ext.Component.applyToMarkup with that element. This in turn "renders" the element keeping it in its original position. Since, the "rendered" flag is now set to true, the call to the Menu.addItem function (that moves the DOM element by calling render with the correct list-item parent ) will fail to do its job. The call to render (item.render(li, this);) will just return without doing any work since the component was already rendered.

evant
22 Oct 2008, 6:20 PM
Confirmed. You could try the following:



Ext.menu.BaseItem = function(config) {
if(config.tagName || config.dom || typeof config == "string") {
this.el = Ext.get(config);
this.el.addClass('x-hide-' + this.hideMode);
config = {};
}
Ext.menu.BaseItem.superclass.constructor.call(this, config);

this.addEvents(
'click',
'activate',
'deactivate'
);

if(this.handler) {
this.on("click", this.handler, this.scope);
}
};


And also add autoShow: true to the BaseItem config.

tryanDLS
21 Apr 2009, 3:03 PM
This has come up again here http://extjs.com/forum/showthread.php?p=319872

Is this considered to be working as designed or a bug that slipped thru the cracks?

widen-av
26 Jan 2010, 3:51 PM
This is still broken using ExtJs 3.0. Any idea when the suggested fix could get added?

mystix
27 Jan 2010, 1:26 AM
[ moved to 3.x Bugs from 2.x Bugs ]
note: bug reportedly affects both 2.x and 3.x branches

Jamie Avins
27 Jan 2010, 6:54 AM
Getting this entered into our tracker to make sure it gets addressed. Looks like there was no feedback as to the efficacy of the proposed solution. Referenced thread seems to have a good test case.

evant
31 Jan 2010, 9:07 PM
A fix for this has been added into SVN for both branches, rev #5959 in 3.x trunk.