diff --git a/src/command/Menus.js b/src/command/Menus.js index 9c9a2cd002a..c1506043897 100644 --- a/src/command/Menus.js +++ b/src/command/Menus.js @@ -844,7 +844,8 @@ define(function (require, exports, module) { */ Menu.prototype.removeSubMenu = function (subMenuID) { var subMenu, - parentMenuItem; + parentMenuItem, + commandID = ""; if (!subMenuID) { console.error("removeSubMenu(): missing required parameters: subMenuID"); @@ -866,6 +867,18 @@ define(function (require, exports, module) { return; } + // Remove all of the menu items in the submenu + _.forEach(menuItemMap, function (value, key) { + if (_.startsWith(key, subMenuID)) { + if (value.isDivider) { + subMenu.removeMenuDivider(key); + } else { + commandID = value.getCommand(); + subMenu.removeMenuItem(commandID); + } + } + }); + if (_isHTMLMenu(this.id)) { $(_getHTMLMenuItem(parentMenuItem.id)).parent().remove(); // remove the menu item $(_getHTMLMenu(subMenuID)).remove(); // remove the menu