From d6c054a9f229bd6a742456440938d1f13e622573 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Thu, 25 Dec 2025 20:47:42 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat(TreeView):=20=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E7=A6=81=E6=AD=A2=E6=97=B6=E5=BC=80=E5=90=AF=20CanExpandWhenDi?= =?UTF-8?q?sabled=20=E4=BB=8D=E7=84=B6=E5=8F=AF=E4=BB=A5=E5=B1=95=E5=BC=80?= =?UTF-8?q?=E8=8A=82=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/TreeView/TreeView.razor.cs | 2 +- .../Components/TreeView/TreeViewRow.razor.cs | 16 +++++++++++++--- .../Extensions/TreeViewExtensions.cs | 4 +--- 3 files changed, 15 insertions(+), 7 deletions(-) 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); } From a29ffa33a127cbac92e05cd63f3795cb3536b926 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Thu, 25 Dec 2025 20:47:48 +0800 Subject: [PATCH 2/3] =?UTF-8?q?test:=20=E6=9B=B4=E6=96=B0=E5=8D=95?= =?UTF-8?q?=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/UnitTest/Components/TreeViewTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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] From 4566b69c088c86fcf577f03f5598ad9676fdd65e Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Thu, 25 Dec 2025 20:48:09 +0800 Subject: [PATCH 3/3] chore: bump version 10.1.5-beta02 --- src/BootstrapBlazor/BootstrapBlazor.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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