Skip to content

Commit

Permalink
Fix menu item deletion (#15500)
Browse files Browse the repository at this point in the history
  • Loading branch information
hishamco authored Mar 21, 2024
1 parent 839bccb commit 28bd184
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -270,16 +270,18 @@ public async Task<IActionResult> Delete(string menuContentItemId, string menuIte
return NotFound();
}

var menuContentAsJson = (JsonObject)menu.Content;
// Look for the target menu item in the hierarchy.
var menuItem = FindMenuItem((JsonObject)menu.Content, menuItemId);
var menuItem = FindMenuItem(menuContentAsJson, menuItemId);

// Couldn't find targeted menu item.
if (menuItem == null)
{
return NotFound();
}

menu.Content.Remove(menuItemId);
var menuItems = menuContentAsJson[nameof(MenuItemsListPart)]?[nameof(MenuItemsListPart.MenuItems)] as JsonArray;
menuItems?.Remove(menuItem);

await _contentManager.SaveDraftAsync(menu);

Expand Down

0 comments on commit 28bd184

Please sign in to comment.