-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix menu item deletion #15500
Fix menu item deletion #15500
Changes from 1 commit
f9bfc19
728554a
a3d66b4
45993ea
64c45af
f41cc8f
df8f93e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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)]["MenuItems"] as JsonArray; | ||
hishamco marked this conversation as resolved.
Show resolved
Hide resolved
|
||
menuItems.Remove(menuItem); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry for the nitpick, but why did you use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, I may have another problem There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sarahelsaig updated , at #15509 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Because there was a logical error in the last change here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you elaborate? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, my English is not good. You can debug the original code, which attempts to remove a menuId directly from a jsonObject There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Thanks for the clarification.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @hyzx86 I've fixed it using the additional "Remove" methods from your branch. Please check out my PR (hyzx86#1003). |
||
|
||
await _contentManager.SaveDraftAsync(menu); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ContentElement.Content
maybe is a instance ofJsonDynamicObject
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, it is