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
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/BootstrapBlazor.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<Version>10.1.5-beta01</Version>
<Version>10.1.5-beta02</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/Components/TreeView/TreeView.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ private async Task OnClick(TreeViewItem<TItem> item)
if (confirm)
{
_activeItem = item;
if (ClickToggleNode && item.CanTriggerClickNode(IsDisabled, CanExpandWhenDisabled))
if (ClickToggleNode)
{
await OnToggleNodeAsync(item);
}
Expand Down
16 changes: 13 additions & 3 deletions src/BootstrapBlazor/Components/TreeView/TreeViewRow.razor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License
// See the LICENSE file in the project root for more information.
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone
Expand Down Expand Up @@ -154,9 +154,19 @@ public partial class TreeViewRow<TItem>
.AddClass("visible", Item.HasChildren || Item.Items.Count > 0)
.AddClass(NodeIcon, !Item.IsExpand)
.AddClass(ExpandNodeIcon, Item.IsExpand)
.AddClass("disabled", !CanTriggerClickNode)
.AddClass("disabled", GetDisabledStatus())
.Build();

private bool GetDisabledStatus()
{
if (IsDisabled || Item.IsDisabled)
{
return !CanExpandWhenDisabled;
}

return false;
}

private string? NodeLoadingClassString => CssBuilder.Default("node-icon node-loading")
.AddClass(LoadingIcon)
.Build();
Expand Down Expand Up @@ -252,7 +262,7 @@ private async Task OnContextMenu(MouseEventArgs e)
return $"--bb-tree-view-level: {level};";
}

private bool CanTriggerClickNode => Item.CanTriggerClickNode(IsDisabled, CanExpandWhenDisabled);
private bool CanTriggerClickNode => !GetDisabledStatus();

private bool ItemDisabledState => Item.IsDisabled || IsDisabled;

Expand Down
4 changes: 1 addition & 3 deletions src/BootstrapBlazor/Extensions/TreeViewExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License
// See the LICENSE file in the project root for more information.
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone
Expand Down Expand Up @@ -68,6 +68,4 @@ public static List<TreeViewItem<TItem>> ToFlat<TItem>(this IEnumerable<TreeViewI
}
return rows;
}

internal static bool CanTriggerClickNode<TItem>(this TreeViewItem<TItem> item, bool isDisabled, bool canExpandWhenDisabled) => !isDisabled && (canExpandWhenDisabled || !item.IsDisabled);
}
2 changes: 1 addition & 1 deletion test/UnitTest/Components/TreeViewTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ public void CanExpandWhenDisabled_Ok()
pb.Add(a => a.IsDisabled, true);
});
node = cut.Find(".node-icon");
Assert.Contains("disabled", node.ClassList);
Assert.DoesNotContain("disabled", node.ClassList);
}

[Fact]
Expand Down
Loading