Skip to content

Commit fed3ce0

Browse files
authored
fix(AutoComplete): skip filter when set SkipMatch to true (#8149)
* fix: 修复 AutoComplete SkipMatch 选中候选项后不生效问题 * test: 更新单元测试 * chore: bump version 10.7.3-beta01 * refactor: 精简代码 * chore: bump version 10.7.3-beta02 * chore: bump version 10.7.3-beta01
1 parent fad4db3 commit fed3ce0

3 files changed

Lines changed: 23 additions & 1 deletion

File tree

‎src/BootstrapBlazor/BootstrapBlazor.csproj‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Razor">
22

33
<PropertyGroup>
4-
<Version>10.7.2</Version>
4+
<Version>10.7.3-beta01</Version>
55
</PropertyGroup>
66

77
<ItemGroup>

‎src/BootstrapBlazor/Components/AutoComplete/AutoComplete.razor.cs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,11 @@ public async Task TriggerClear()
237237
[JSInvokable]
238238
public async Task TriggerFilter(string val)
239239
{
240+
if (SkipMatch)
241+
{
242+
return;
243+
}
244+
240245
if (OnCustomFilter != null)
241246
{
242247
var items = await OnCustomFilter(val);

‎test/UnitTest/Components/AutoCompleteTest.cs‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,23 @@ public void SkipMatch_Ok()
2323
Assert.Equal(4, items.Count);
2424
}
2525

26+
[Fact]
27+
public async Task SkipMatch_AfterSelect_Ok()
28+
{
29+
var cut = Context.Render<AutoComplete>(pb =>
30+
{
31+
pb.Add(a => a.SkipMatch, true);
32+
pb.Add(a => a.Items, new List<string>() { "test1", "test12", "test123", "test1234" });
33+
});
34+
35+
// 选中候选项 test123 后 TriggerFilter 不应过滤候选项
36+
// 否则再次输入时 SkipMatch 失效 候选项被锁定为上次选中值的过滤子集
37+
await cut.InvokeAsync(() => cut.FindAll(".dropdown-item")[2].Click());
38+
39+
var items = cut.FindAll(".dropdown-item");
40+
Assert.Equal(4, items.Count);
41+
}
42+
2643
[Fact]
2744
public void Items_Ok()
2845
{

0 commit comments

Comments
 (0)