View Full Version : [2.x] Only show menu when it has visible menu items

5 Mar 2009, 8:41 AM
Not really an extension, just a simple addition to Ext.menu.Menu. I frequently hide certain menu items based on different permissions. As such when i call showAt on the menu at the menu is empty I do not want the menu to appear (if it does you just get a thin grey bar). This fixes this issue:

// menu showAt to only work when the menu has some visible items
Ext.apply(Ext.menu.Menu.prototype, {
doShowAt : Ext.menu.Menu.prototype.showAt,
showAt : function(xy, parentMenu, _e) {
var hasVisible = false;
this.items.each(function(item) {
if (!item.hidden) {
hasVisible = true;
return false;
if (hasVisible) {
this.doShowAt(xy, parentMenu, _e);