Skip to content

Commit

Permalink
bug(ValidaetForm): do not show label when InputGroup inside ValidateF…
Browse files Browse the repository at this point in the history
…orm (#4003)

* refactor: 更改为可为空类型

* test: 更新单元测试

* test: 更新单元测试

* chore: bump version 8.8.2-beta04
  • Loading branch information
ArgoZhang authored Aug 8, 2024
1 parent acb412a commit e9e23e6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
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>8.8.2-beta03</Version>
<Version>8.8.2-beta04</Version>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ public partial class ValidateForm
public bool ShowRequiredMark { get; set; } = true;

/// <summary>
/// 获得/设置 是否显示验证表单内的 Label 默认为 显示
/// 获得/设置 是否显示验证表单内的 Label 默认为 null
/// </summary>
[Parameter]
public bool ShowLabel { get; set; } = true;
public bool? ShowLabel { get; set; }

/// <summary>
/// 获得/设置 是否显示标签 Tooltip 多用于标签文字过长导致裁减时使用 默认 null
Expand Down
2 changes: 1 addition & 1 deletion test/UnitTest/Components/DisplayTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public void Bind_Ok()
});
Assert.Contains("is-display", cut.Markup);
Assert.Contains("input-group-text", cut.Markup);
Assert.Contains("<span>姓名</span>", cut.Markup);
Assert.DoesNotContain("<span>姓名</span>", cut.Markup);
}

[Fact]
Expand Down
11 changes: 7 additions & 4 deletions test/UnitTest/Components/ValidateTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ public void ValidateForm_Group_Ok()
builder.Add(a => a.Model, model);
builder.AddChildContent<BootstrapInputGroup>(pb =>
{
pb.AddChildContent<BootstrapInputGroupLabel>(p =>
{
p.Add(a => a.DisplayText, "Name-Test");
});
pb.AddChildContent<BootstrapInput<string>>(p =>
{
p.Add(a => a.Value, model.Name);
Expand All @@ -108,15 +112,14 @@ public void ValidateForm_Group_Ok()
});

// ValidateForm 验证表单中 使用 InputGroup 组件
var group = cut.FindComponent<BootstrapInputGroup>();
group.Contains("姓名");
cut.Contains("Name-Test");

var input = cut.FindComponent<BootstrapInput<string>>();
input.SetParametersAndRender(pb =>
{
pb.Add(a => a.ShowLabel, false);
pb.Add(a => a.ShowLabel, true);
});
group.DoesNotContain("姓名");
cut.Contains("姓名");
}

[Fact]
Expand Down

0 comments on commit e9e23e6

Please sign in to comment.