diff --git a/examples/Demo/Shared/Pages/NavMenu/Examples/NavMenuCollapsible.razor b/examples/Demo/Shared/Pages/NavMenu/Examples/NavMenuCollapsible.razor index c618664d14..a5d3354741 100644 --- a/examples/Demo/Shared/Pages/NavMenu/Examples/NavMenuCollapsible.razor +++ b/examples/Demo/Shared/Pages/NavMenu/Examples/NavMenuCollapsible.razor @@ -2,18 +2,31 @@
- + Item 1 - Item 2 + Item 2 Item 3.1 - Item 3.2 - - Item 4 + Item 3.2 + + https://microsoft.com + + + https://microsoft.com + + + Item 4 + + Item 5.1 + + Item 6
- +
+ +
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce quis lorem lacus. Ut id leo non enim feugiat ultrices. Proin vulputate volutpat urna nec iaculis. Integer dui lacus, fermentum sit amet aliquet in, scelerisque vitae dui. @@ -23,11 +36,12 @@ Sed maximus, urna in fringilla posuere, enim urna bibendum justo, vel molestie nibh orci nec lectus. Etiam a varius justo. Aenean nisl ante, interdum eget vulputate eget, iaculis ut massa. Suspendisse maximus sed purus id molestie. Lorem ipsum dolor sit amet, consectetur adipiscing elit. - +
@code { bool Expanded = true; -} \ No newline at end of file + bool EnableCollapsedChildNavigation = true; +} diff --git a/examples/Demo/Shared/Pages/NavMenu/NavMenuPage.razor b/examples/Demo/Shared/Pages/NavMenu/NavMenuPage.razor index aacdd286d3..206a726339 100644 --- a/examples/Demo/Shared/Pages/NavMenu/NavMenuPage.razor +++ b/examples/Demo/Shared/Pages/NavMenu/NavMenuPage.razor @@ -52,7 +52,13 @@ - More complete example which shows how the menu works together with a text section when it collapses. +

+ More complete example which shows how the menu works together with a text section when it collapses. + When CollapsedChildNavigation is set to true, clicking on a FluentNavGroup opens a menu containing all links included in that group. +

+

+ Note that menu items without an icon are not visible when the menu is collapsed. +

diff --git a/src/Core/Components/Menu/FluentMenu.razor b/src/Core/Components/Menu/FluentMenu.razor index 4f7026af9f..f6bf390b1e 100644 --- a/src/Core/Components/Menu/FluentMenu.razor +++ b/src/Core/Components/Menu/FluentMenu.razor @@ -8,9 +8,9 @@ - /// Gets or sets the menu position (left or right). + /// Gets or sets the horizontal menu position. /// [Parameter] public HorizontalPosition HorizontalPosition { get; set; } = HorizontalPosition.Unset; + /// + /// Gets or sets a value indicating whether the region overlaps the anchor on the horizontal axis. + /// Default is false which places the region adjacent to the anchor element. + /// + [Parameter] + public bool HorizontalInset { get; set; } = true; + + /// + /// Gets or sets the vertical menu position. + /// + [Parameter] + public VerticalPosition VerticalPosition { get; set; } = VerticalPosition.Bottom; + + /// + /// Gets or sets a value indicating whether the region overlaps the anchor on the vertical axis. + /// + [Parameter] + public bool VerticalInset { get; set; } = false; + /// /// Gets or sets the width of this menu. /// diff --git a/src/Core/Components/Menu/FluentMenuItem.razor.cs b/src/Core/Components/Menu/FluentMenuItem.razor.cs index d205b1e8c6..e1d5defcbf 100644 --- a/src/Core/Components/Menu/FluentMenuItem.razor.cs +++ b/src/Core/Components/Menu/FluentMenuItem.razor.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Web; namespace Microsoft.FluentUI.AspNetCore.Components; @@ -56,7 +57,7 @@ public partial class FluentMenuItem : FluentComponentBase, IDisposable /// Event raised when the user click on this item. /// [Parameter] - public EventCallback OnClick { get; set; } + public EventCallback OnClick { get; set; } public FluentMenuItem() { @@ -69,7 +70,7 @@ protected override void OnInitialized() } /// - protected async Task OnClickHandlerAsync() + protected async Task OnClickHandlerAsync(MouseEventArgs ev) { if (Disabled) { @@ -81,7 +82,7 @@ protected async Task OnClickHandlerAsync() await Owner.CloseAsync(); } - await OnClick.InvokeAsync(); + await OnClick.InvokeAsync(ev); } protected string? GetRole() diff --git a/src/Core/Components/NavMenu/FluentNavBase.cs b/src/Core/Components/NavMenu/FluentNavBase.cs index 9497dcd06b..b3eff5dab8 100644 --- a/src/Core/Components/NavMenu/FluentNavBase.cs +++ b/src/Core/Components/NavMenu/FluentNavBase.cs @@ -70,6 +70,9 @@ public abstract class FluentNavBase : FluentComponentBase [CascadingParameter] public FluentNavMenu Owner { get; set; } = default!; + [CascadingParameter] + public FluentMenu? SubMenu { get; set; } + /// /// Returns if the item has an set. /// @@ -106,7 +109,7 @@ protected async Task OnClickHandlerAsync(MouseEventArgs ev) } else { - if (!Owner.Expanded) + if (!Owner.Expanded && !Owner.CollapsedChildNavigation && SubMenu == null) { await Owner.ExpandedChanged.InvokeAsync(true); } diff --git a/src/Core/Components/NavMenu/FluentNavGroup.razor b/src/Core/Components/NavMenu/FluentNavGroup.razor index 2f2d7faaad..55487de6c8 100644 --- a/src/Core/Components/NavMenu/FluentNavGroup.razor +++ b/src/Core/Components/NavMenu/FluentNavGroup.razor @@ -3,7 +3,7 @@ @using Microsoft.AspNetCore.Components.Rendering @using Microsoft.AspNetCore.Components.Routing -@if (Owner.Expanded || HasIcon) +@if (Owner.Expanded || (HasIcon && (!Owner.CollapsedChildNavigation || SubMenu == null))) {