diff --git a/src/BootstrapBlazor/BootstrapBlazor.csproj b/src/BootstrapBlazor/BootstrapBlazor.csproj index 230a6d860cf..a564b115e62 100644 --- a/src/BootstrapBlazor/BootstrapBlazor.csproj +++ b/src/BootstrapBlazor/BootstrapBlazor.csproj @@ -1,7 +1,7 @@ - 10.1.5-beta01 + 10.1.5-beta02 diff --git a/src/BootstrapBlazor/Components/TreeView/TreeView.razor.cs b/src/BootstrapBlazor/Components/TreeView/TreeView.razor.cs index c4d7db5098b..063b20b7ba5 100644 --- a/src/BootstrapBlazor/Components/TreeView/TreeView.razor.cs +++ b/src/BootstrapBlazor/Components/TreeView/TreeView.razor.cs @@ -605,7 +605,7 @@ private async Task OnClick(TreeViewItem item) if (confirm) { _activeItem = item; - if (ClickToggleNode && item.CanTriggerClickNode(IsDisabled, CanExpandWhenDisabled)) + if (ClickToggleNode) { await OnToggleNodeAsync(item); } diff --git a/src/BootstrapBlazor/Components/TreeView/TreeViewRow.razor.cs b/src/BootstrapBlazor/Components/TreeView/TreeViewRow.razor.cs index a794b95272d..d3f59b5c3ab 100644 --- a/src/BootstrapBlazor/Components/TreeView/TreeViewRow.razor.cs +++ b/src/BootstrapBlazor/Components/TreeView/TreeViewRow.razor.cs @@ -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(argo@live.ca) Website: https://www.blazor.zone @@ -154,9 +154,19 @@ public partial class TreeViewRow .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(); @@ -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; diff --git a/src/BootstrapBlazor/Extensions/TreeViewExtensions.cs b/src/BootstrapBlazor/Extensions/TreeViewExtensions.cs index d232ff923fa..e5581df3983 100644 --- a/src/BootstrapBlazor/Extensions/TreeViewExtensions.cs +++ b/src/BootstrapBlazor/Extensions/TreeViewExtensions.cs @@ -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(argo@live.ca) Website: https://www.blazor.zone @@ -68,6 +68,4 @@ public static List> ToFlat(this IEnumerable(this TreeViewItem item, bool isDisabled, bool canExpandWhenDisabled) => !isDisabled && (canExpandWhenDisabled || !item.IsDisabled); } diff --git a/test/UnitTest/Components/TreeViewTest.cs b/test/UnitTest/Components/TreeViewTest.cs index c22d862c4a6..9aff84ebb02 100644 --- a/test/UnitTest/Components/TreeViewTest.cs +++ b/test/UnitTest/Components/TreeViewTest.cs @@ -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]