PDA

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



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

Ext 3.0 rev rc2




Browser versions tested against:
FF2.0.0.20
[ ]IE8

[ ]FF3 (firebug 1.3.0.10 installed)

[ ]Safari 4




Operating System:


WinXP Pro




Description:
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':
break;

case 'idCmsTreeButNew':
break;
case 'idCmsTreeButNewFolder':
break;

case 'idCmsTreeButNewGroup':
break;

case 'idCmsTreeButDelete':
break;

case 'idCmsTreeButProperty':
break;
}
}
}
});








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:

attached




Debugging already done:

none




Possible fix:

not provided

Condor
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).

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

sergiu079
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.

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

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