Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/Demo/Shared/Shared/DemoNavMenuItem.razor
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
@using NavLink = FluentUI.Demo.Shared.NavLink

@switch(Value)
@switch (Value)
{
case NavGroup group:
<FluentNavGroup Expanded="@group.Expanded" Gap="@group.Gap" Icon="@group.Icon">
<FluentNavGroup @bind-Expanded="@group.Expanded" Gap="@group.Gap" Icon="@group.Icon" >
<TitleTemplate>
<h3>@group.Title</h3></TitleTemplate>
<ChildContent>
Expand Down
4 changes: 2 additions & 2 deletions examples/Demo/Shared/Shared/NavItem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// MIT License - Copyright (c) Microsoft Corporation. All rights reserved.
// ------------------------------------------------------------------------

Expand Down Expand Up @@ -28,7 +28,7 @@ public NavLink(string? href, Icon icon, string title, NavLinkMatch match = NavLi

public record NavGroup : NavItem
{
public bool Expanded { get; init; }
public bool Expanded { get; set; }
public string Gap { get; init; }
public IReadOnlyList<NavItem> Children { get; }

Expand Down
19 changes: 1 addition & 18 deletions src/Core/Components/NavMenu/FluentNavGroup.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ public partial class FluentNavGroup : FluentNavBase
private readonly RenderFragment _renderButton;
private bool _open;

private static int _renderCount = 0;
private static bool _negate = false;

protected string? ClassValue =>
new CssBuilder("fluent-nav-group")
.AddClass("fluent-nav-item")
Expand Down Expand Up @@ -105,30 +102,16 @@ public FluentNavGroup()
_renderButton = RenderButton;
}

protected override void OnInitialized()
{
_renderCount ++;
if (_renderCount > 1)
{
_negate = true;
}
}

private async Task ToggleExpandedAsync()
{

if (_negate)
{
Expanded = !Expanded;
}

if (!Owner.Expanded && Owner.CollapsedChildNavigation)
{
await SetExpandedAsync(!_open);
}
else
{
await SetExpandedAsync(Expanded);
await SetExpandedAsync(!Expanded);
}
}

Expand Down