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;