mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-12-03 12:03:51 +08:00
#19222: Fixing the case when the current path is not part of a menu structure, causing Menu widgets to render ALL child items when configured with a StartLevel > 1. Fixed a related issue when configured as Breadcrumb.
Work Item: 19222 --HG-- branch : 1.x
This commit is contained in:
@@ -80,8 +80,8 @@ namespace Orchard.Core.Navigation.Drivers {
|
|||||||
|
|
||||||
dynamic menuShape = shapeHelper.Menu();
|
dynamic menuShape = shapeHelper.Menu();
|
||||||
|
|
||||||
if (part.Breadcrumb && selectedPath != null) {
|
if (part.Breadcrumb) {
|
||||||
menuItems = selectedPath;
|
menuItems = selectedPath ?? new Stack<MenuItem>();
|
||||||
foreach (var menuItem in menuItems) {
|
foreach (var menuItem in menuItems) {
|
||||||
menuItem.Items = Enumerable.Empty<MenuItem>();
|
menuItem.Items = Enumerable.Empty<MenuItem>();
|
||||||
}
|
}
|
||||||
@@ -119,10 +119,16 @@ namespace Orchard.Core.Navigation.Drivers {
|
|||||||
else {
|
else {
|
||||||
IEnumerable<MenuItem> topLevelItems = menuItems.ToList();
|
IEnumerable<MenuItem> topLevelItems = menuItems.ToList();
|
||||||
|
|
||||||
if (part.StartLevel > 1 && selectedPath != null) {
|
if (part.StartLevel > 1) {
|
||||||
// the selected path will return the whole selected hierarchy
|
if (selectedPath != null) {
|
||||||
// intersecting will return the root selected menu item
|
// the selected path will return the whole selected hierarchy
|
||||||
topLevelItems = topLevelItems.Intersect(selectedPath.Where(x => x.Selected)).ToList();
|
// intersecting will return the root selected menu item
|
||||||
|
topLevelItems = topLevelItems.Intersect(selectedPath.Where(x => x.Selected)).ToList();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
topLevelItems = new List<MenuItem>();
|
||||||
|
menuItems = topLevelItems;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (topLevelItems.Any()) {
|
if (topLevelItems.Any()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user