From b01bfa8f9df45cb45fbcfbe1666f86d51dca7a80 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sat, 26 Apr 2025 17:35:41 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=20ChildContent?= =?UTF-8?q?=20=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Input/BootstrapInputGroupLabel.razor | 20 +++++++++++++++++-- .../Input/BootstrapInputGroupLabel.razor.cs | 6 ++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.razor b/src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.razor index 135fcb291e8..1904f073e6c 100644 --- a/src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.razor +++ b/src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.razor @@ -4,10 +4,26 @@ @if (IsInputGroupLabel) {
- @DisplayText + @if (ChildContent != null) + { + @ChildContent + } + else + { + @DisplayText + }
} else { - + } diff --git a/src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.razor.cs b/src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.razor.cs index a5d4af2405b..8352b0e1ec4 100644 --- a/src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.razor.cs +++ b/src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.razor.cs @@ -41,6 +41,12 @@ public partial class BootstrapInputGroupLabel [Parameter] public bool ShowRequiredMark { get; set; } + /// + /// Gets or sets the child content. Default is null. + /// + [Parameter] + public RenderFragment? ChildContent { get; set; } + private string? Required => ShowRequiredMark ? "true" : null; private bool IsInputGroupLabel => InputGroup != null; From cb3e0b0e74fb23bb380dcf00363490772d72dc30 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 27 Apr 2025 08:42:21 +0800 Subject: [PATCH 2/2] =?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/InputTest.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/UnitTest/Components/InputTest.cs b/test/UnitTest/Components/InputTest.cs index 2df97903e1b..1abadf077ce 100644 --- a/test/UnitTest/Components/InputTest.cs +++ b/test/UnitTest/Components/InputTest.cs @@ -273,6 +273,13 @@ public void GroupLabel_Ok() }); Assert.Contains("DisplayText", cut.Markup); + + cut.SetParametersAndRender(pb => + { + pb.Add(a => a.ChildContent, builder => builder.AddContent(0, "test-child-content")); + }); + cut.Contains("test-child-content"); + cut.DoesNotContain("DisplayText"); } [Fact]