mirror of
https://gitee.com/LongbowEnterprise/BootstrapBlazor.git
synced 2024-12-02 03:59:14 +08:00
!2726 fix(#I55BRE): not set Value when click label text
* chore: bump version 6.5.15 * test: 增加单元测试 * fix: 增加选中状态翻转代码 * test: 补充单元测试 * feat: 支持点击 TreeItem 节点标签逻辑 * fix: 修复选中文本取不到 Value
This commit is contained in:
parent
6e0515caaa
commit
f24ef999c5
@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
||||
|
||||
<PropertyGroup>
|
||||
<Version>6.5.14</Version>
|
||||
<Version>6.5.15</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
|
||||
|
@ -196,6 +196,17 @@ public partial class Tree
|
||||
{
|
||||
await OnTreeItemClick(item);
|
||||
}
|
||||
|
||||
if (ShowRadio)
|
||||
{
|
||||
await OnRadioClick(item);
|
||||
}
|
||||
else if (ShowCheckbox)
|
||||
{
|
||||
item.Checked = !item.Checked;
|
||||
var status = item.Checked ? CheckboxState.Checked : CheckboxState.UnChecked;
|
||||
await OnStateChanged(status, item);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -31,13 +31,57 @@ public class TreeTest : BootstrapBlazorTestBase
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OnClick_Ok()
|
||||
public async Task OnClick_Checkbox_Ok()
|
||||
{
|
||||
var tcs = new TaskCompletionSource<bool>();
|
||||
bool itemChecked = false;
|
||||
var cut = Context.RenderComponent<Tree>(pb =>
|
||||
{
|
||||
pb.Add(a => a.IsAccordion, true);
|
||||
pb.Add(a => a.ShowCheckbox, true);
|
||||
pb.Add(a => a.OnTreeItemChecked, items =>
|
||||
{
|
||||
itemChecked = items.FirstOrDefault()?.Checked ?? false;
|
||||
tcs.SetResult(true);
|
||||
return Task.CompletedTask;
|
||||
});
|
||||
pb.Add(a => a.Items, new List<TreeItem>()
|
||||
{
|
||||
new TreeItem()
|
||||
{
|
||||
Text = "Test1",
|
||||
Items = new List<TreeItem>()
|
||||
{
|
||||
new TreeItem()
|
||||
{
|
||||
Text = "Test11",
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 测试点击选中
|
||||
await cut.InvokeAsync(() => cut.Find(".tree-node").Click());
|
||||
await tcs.Task;
|
||||
Assert.True(itemChecked);
|
||||
|
||||
// 测试取消选中
|
||||
tcs = new TaskCompletionSource<bool>();
|
||||
await cut.InvokeAsync(() => cut.Find(".tree-node").Click());
|
||||
await tcs.Task;
|
||||
Assert.False(itemChecked);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task OnClick_Ok()
|
||||
{
|
||||
var clicked = false;
|
||||
var expanded = false;
|
||||
var cut = Context.RenderComponent<Tree>(pb =>
|
||||
{
|
||||
pb.Add(a => a.IsAccordion, true);
|
||||
pb.Add(a => a.ShowRadio, true);
|
||||
pb.Add(a => a.ClickToggleNode, true);
|
||||
pb.Add(a => a.OnTreeItemClick, item =>
|
||||
{
|
||||
@ -77,7 +121,7 @@ public class TreeTest : BootstrapBlazorTestBase
|
||||
});
|
||||
});
|
||||
|
||||
cut.InvokeAsync(() => cut.Find(".tree-node").Click());
|
||||
await cut.InvokeAsync(() => cut.Find(".tree-node").Click());
|
||||
Assert.True(clicked);
|
||||
Assert.True(expanded);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user