Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Commit

Permalink
Remove menu items in sub menu before deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
boopeshmahendran committed Nov 10, 2017
1 parent c9e1ee1 commit 5616075
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/command/Menus.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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
Expand Down

0 comments on commit 5616075

Please sign in to comment.