PDA

View Full Version : [FIXED][DUP][3.0] ColorMenu et al



stever
10 Apr 2009, 12:56 PM
If you create a color menu like this:


new Ext.menu.ColorMenu({
listeners:{
select: ...


Your select handler will get called twice. The color palette will get it from the initial config and it will get relayed to the menu which will then also call it.


Ext.menu.ColorMenu = Ext.extend(Ext.menu.Menu, {
...
initComponent: function(){
Ext.apply(this, {
plain: true,
showSeparator: false,
items: this.palette = new Ext.ColorPalette(this.initialConfig)
});
Ext.menu.ColorMenu.superclass.initComponent.call(this);
this.relayEvents(this.palette, ['select']);
},

Condor
11 Apr 2009, 12:07 AM
Duplicate of this bugreport (http://www.extjs.com/forum/showthread.php?p=216567#post216567) (same bug applies to DateMenu).

evant
12 May 2009, 4:04 AM
Fixed in SVN.

Animal
12 May 2009, 5:49 AM
This fixes are inconsistent.

The fix in DateMenu applies initialConfig (Containing the listeners) to a config option containing listeners: null. The null will be overwritten, and the listeners will end up in the DatePicker.

The fix in ColorMenu applies {listeners: null} to the initialConfig object before using that to create the ColorPalette.

Mutating the initialConfig object is a Bad Idea. A Component does not own it. Outside application code owns it, and might reuse it to create other Components. Think factory function.

evant
12 May 2009, 7:21 AM
I've modified this, I don't think the solution is that great but upon instantiation it purges any listeners. On the odd case you want to bind a listener to the underlying component, then you can still do so manually.