Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/BootstrapBlazor.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<Version>9.7.1-beta01</Version>
<Version>9.7.1-beta02</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
10 changes: 0 additions & 10 deletions src/BootstrapBlazor/Components/BaseComponents/IdComponentBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,6 @@ public abstract class IdComponentBase : BootstrapComponentBase
/// </summary>
protected virtual string? RetrieveId() => Id;

/// <summary>
/// <inheritdoc/>
/// </summary>
protected override void OnInitialized()
{
base.OnInitialized();

Id ??= ComponentIdGenerator.Generate(this);
}

/// <summary>
/// <inheritdoc/>
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/Components/Tab/TabItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace BootstrapBlazor.Components;
/// <summary>
/// TabItem component
/// </summary>
public class TabItem : ComponentBase
public class TabItem : IdComponentBase
{
/// <summary>
/// Gets or sets the text. Default is null
Expand Down
9 changes: 1 addition & 8 deletions src/BootstrapBlazor/Components/Tab/TabItemContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@ internal class TabItemContent : IComponent
[Parameter, NotNull]
public TabItem? Item { get; set; }

/// <summary>
/// Gets <see cref="IComponentIdGenerator"/> instrance
/// </summary>
[Inject]
[NotNull]
private IComponentIdGenerator? ComponentIdGenerator { get; set; }

private RenderHandle _renderHandle;

void IComponent.Attach(RenderHandle renderHandle)
Expand Down Expand Up @@ -49,7 +42,7 @@ private void BuildRenderTree(RenderTreeBuilder builder)
builder.OpenElement(0, "div");
builder.SetKey(_key);
builder.AddAttribute(5, "class", ClassString);
builder.AddAttribute(6, "id", ComponentIdGenerator.Generate(Item));
builder.AddAttribute(6, "id", Item.Id);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Directly using Item.Id may produce a null id attribute

Consider using a helper like RetrieveId() or generating a fallback value to ensure the id attribute is always valid and unique when Item.Id is null.

builder.AddContent(10, Item.ChildContent);
builder.CloseElement();
}
Expand Down