View Full Version : [CLOSED][3.??] Context menu shows twice

19 Jun 2009, 5:36 AM
Ext version tested:

Ext 3.0 rev rc2

Browser versions tested against:
[ ]IE8

[ ]FF3 (firebug installed)

[ ]Safari 4

Operating System:

WinXP Pro

When I right-click on a tree-node first-time, everything is ok, but when I right-click the second time and the third-time and so on,
the elements of the context-menu appear twice. If I add an id for the menu, when I right-click the second time the items appear twice, when I right-click the third time the items appear 3 times, and so on
See screenshot

Test Case:

Navigation.TreeContextMenu = Ext.extend(Ext.menu.Menu,{
//id: 'ContextMenu',
initComponent:function() {
var config = {
items: [
id: 'idCmsTreeButOpen',
text: '<b>'+'Open'+'</b>'
id: 'idCmsTreeButNew',
text: 'Add new item'
id: 'idCmsTreeButNewFolder',
text: 'New folder'
id: 'idCmsTreeButNewGroup',
text: lang['New group']
text: 'Move to...',
menu: {
items: [{}]
id: 'idCmsTreeButDelete',
text: 'Delete' // remove
id: 'idCmsTreeButProperty',
text: 'Properties' // properties
Ext.apply(this, Ext.apply(this.initialConfig, config));
Navigation.TreeContextMenu.superclass.initComponent.apply(this, arguments);

listeners: {

/** @event itemclick
* Fires after a context menu item is clicked.
* @param {Ext.menu.BaseItem} item The item that was clicked
* @param {Ext.EventObject} e
itemclick: function(item,e) {
var treenode = item.parentMenu.contextNode;

switch (item.id) {
case 'idCmsTreeButOpen':

case 'idCmsTreeButNew':
case 'idCmsTreeButNewFolder':

case 'idCmsTreeButNewGroup':

case 'idCmsTreeButDelete':

case 'idCmsTreeButProperty':

The result that was expected:

Every context menu item should appear once

The result that occurs instead:

Every context menu item should appear twice

Screenshot or Video:


Debugging already done:


Possible fix:

not provided

19 Jun 2009, 5:45 AM
In Ext 3 menu items are components. This means the the ids you assign need to be unique.

Are you sure you are not using the ids somewhere else or are create 2 menus with the same ids?

ps. I would recommend using itemId instead of id here (itemId only needs to be unqiue within the container = the menu).

19 Jun 2009, 5:46 AM
All you've included here is the menu creation code, how are you using it with the tree?

19 Jun 2009, 6:24 AM
Thank you Condor,
Your answer was awesome, I replaced the id with the itemId and it worked.
Now I have to do that all over my application, wherever I have contextual menus.
Thanks again, nice job.

19 Jun 2009, 6:26 AM
@evant: This should go on the list of breaking changes (even Ext itself suffered from it).

19 Jun 2009, 6:47 AM
Will do, marking this as closed.