From 5616075ba898a10e7b221f7ffb6a1116a6f40432 Mon Sep 17 00:00:00 2001 From: Boopesh Mahendran Date: Fri, 10 Nov 2017 17:14:59 +0530 Subject: [PATCH] Remove menu items in sub menu before deletion --- src/command/Menus.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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