diff --git a/src/BootstrapBlazor/BootstrapBlazor.csproj b/src/BootstrapBlazor/BootstrapBlazor.csproj index c1b8c47a501..47812daf5d9 100644 --- a/src/BootstrapBlazor/BootstrapBlazor.csproj +++ b/src/BootstrapBlazor/BootstrapBlazor.csproj @@ -1,7 +1,7 @@  - 9.8.0-beta01 + 9.8.0-beta02 diff --git a/src/BootstrapBlazor/Components/Tab/Tab.razor b/src/BootstrapBlazor/Components/Tab/Tab.razor index 0575273eae3..c52ed0ab0f5 100644 --- a/src/BootstrapBlazor/Components/Tab/Tab.razor +++ b/src/BootstrapBlazor/Components/Tab/Tab.razor @@ -24,14 +24,18 @@ else var item = TabItems.Find(i => i.IsActive); if (item != null) { - @RenderTabItem(item) +
+ @RenderTabItem(item) +
} } else { foreach (var item in TabItems) { - @RenderTabItem(item) +
+ @RenderTabItem(item) +
} } diff --git a/src/BootstrapBlazor/Components/Tab/Tab.razor.cs b/src/BootstrapBlazor/Components/Tab/Tab.razor.cs index 2572e9c1d9d..9057cb18e9b 100644 --- a/src/BootstrapBlazor/Components/Tab/Tab.razor.cs +++ b/src/BootstrapBlazor/Components/Tab/Tab.razor.cs @@ -486,6 +486,10 @@ public partial class Tab private bool IsPreventDefault => _contextMenuZone != null; + private static string? GetTabItemClassString(TabItem item) => CssBuilder.Default("tabs-body-content") + .AddClass("d-none", item is { IsActive: false }) + .Build(); + /// /// /// @@ -1054,7 +1058,7 @@ public async Task DragItemCallback(int originIndex, int currentIndex) private async Task OnRefreshAsync() { // refresh the active tab item - var item = TabItems.FirstOrDefault(i => i.IsActive); + var item = TabItems.Find(i => i.IsActive); if (item is not null) { diff --git a/src/BootstrapBlazor/Components/Tab/TabItemContent.cs b/src/BootstrapBlazor/Components/Tab/TabItemContent.cs index 04cb2ad5026..72bf49a2232 100644 --- a/src/BootstrapBlazor/Components/Tab/TabItemContent.cs +++ b/src/BootstrapBlazor/Components/Tab/TabItemContent.cs @@ -47,14 +47,13 @@ private void RenderContent() _renderHandle.Render(BuildRenderTree); } - private object _key = new(); + private Guid _key = Guid.NewGuid(); private void BuildRenderTree(RenderTreeBuilder builder) { builder.OpenElement(0, "div"); builder.SetKey(_key); - builder.AddAttribute(5, "class", ClassString); - builder.AddAttribute(6, "id", Item.Id); + builder.AddAttribute(5, "class", "tabs-body-content-wrap"); builder.AddContent(10, RenderItemContent(Item.ChildContent)); builder.CloseElement(); } @@ -79,16 +78,12 @@ private RenderFragment RenderItemContent(RenderFragment? content) => builder => builder.CloseComponent(); }; - private string? ClassString => CssBuilder.Default("tabs-body-content") - .AddClass("d-none", !Item.IsActive) - .Build(); - /// /// Render method /// public void Render() { - _key = new object(); + _key = Guid.NewGuid(); RenderContent(); }