From a85f81edf20041b3b1fff907bfdc07c1f65890c4 Mon Sep 17 00:00:00 2001 From: Argo Date: Tue, 10 Jan 2023 14:06:14 +0000 Subject: [PATCH] =?UTF-8?q?!3747=20fix(#I69VFA):=20update=20RibbonTab=20ma?= =?UTF-8?q?ke=20sure=20have=20IsActive=20item=20*=20chore:=20bump=20versio?= =?UTF-8?q?n=207.2.3-beta02=20*=20fix:=20=E4=BF=AE=E5=A4=8D=20RibbonTab=20?= =?UTF-8?q?=E5=8F=AF=E8=83=BD=E5=AF=BC=E8=87=B4=E4=BA=8C=E7=BA=A7=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E4=B8=8D=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/BootstrapBlazor.csproj | 2 +- .../Components/RibbonTab/RibbonTab.razor | 2 +- .../Components/RibbonTab/RibbonTab.razor.cs | 25 ++++++++++++++++--- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/BootstrapBlazor/BootstrapBlazor.csproj b/src/BootstrapBlazor/BootstrapBlazor.csproj index 69efcb15d..a8006c2e0 100644 --- a/src/BootstrapBlazor/BootstrapBlazor.csproj +++ b/src/BootstrapBlazor/BootstrapBlazor.csproj @@ -1,7 +1,7 @@ - 7.2.3-beta01 + 7.2.3-beta02 diff --git a/src/BootstrapBlazor/Components/RibbonTab/RibbonTab.razor b/src/BootstrapBlazor/Components/RibbonTab/RibbonTab.razor index ad9a5d75a..e2faad1d4 100644 --- a/src/BootstrapBlazor/Components/RibbonTab/RibbonTab.razor +++ b/src/BootstrapBlazor/Components/RibbonTab/RibbonTab.razor @@ -4,7 +4,7 @@
- @foreach (var item in GetItems()) + @foreach (var item in Items) {
diff --git a/src/BootstrapBlazor/Components/RibbonTab/RibbonTab.razor.cs b/src/BootstrapBlazor/Components/RibbonTab/RibbonTab.razor.cs index 0a1d038bc..a04911d9c 100644 --- a/src/BootstrapBlazor/Components/RibbonTab/RibbonTab.razor.cs +++ b/src/BootstrapBlazor/Components/RibbonTab/RibbonTab.razor.cs @@ -52,6 +52,7 @@ public partial class RibbonTab /// 获得/设置 数据源 /// [Parameter] + [NotNull] #if NET6_0_OR_GREATER [EditorRequired] #endif @@ -106,6 +107,24 @@ public partial class RibbonTab /// protected override Task ModuleInitAsync() => InvokeInitAsync(Id, nameof(SetExpand)); + /// + /// + /// + protected override void OnParametersSet() + { + base.OnParametersSet(); + + Items ??= Enumerable.Empty(); + if (!Items.Any(i => i.IsActive)) + { + var item = Items.FirstOrDefault(); + if (item != null) + { + item.IsActive = true; + } + } + } + /// /// SetExpand 方法 /// @@ -126,12 +145,12 @@ public partial class RibbonTab private async Task OnClickTab(TabItem item) { - var tab = GetItems().FirstOrDefault(i => i.IsActive); + var tab = Items.FirstOrDefault(i => i.IsActive); if (tab != null) { tab.IsActive = false; } - tab = GetItems().First(i => i.Text == item.Text); + tab = Items.First(i => i.Text == item.Text); tab.IsActive = true; if (OnMenuClickAsync != null) { @@ -144,8 +163,6 @@ public partial class RibbonTab } } - private IEnumerable GetItems() => Items ?? Enumerable.Empty(); - private async Task OnToggleFloat() { IsFloat = !IsFloat;