diff --git a/src/BootstrapBlazor/BootstrapBlazor.csproj b/src/BootstrapBlazor/BootstrapBlazor.csproj index 81fcfa984f7..26e16d5f31c 100644 --- a/src/BootstrapBlazor/BootstrapBlazor.csproj +++ b/src/BootstrapBlazor/BootstrapBlazor.csproj @@ -1,7 +1,7 @@ - 9.1.3-beta08 + 9.1.3 diff --git a/src/BootstrapBlazor/Components/Dropdown/Dropdown.razor.cs b/src/BootstrapBlazor/Components/Dropdown/Dropdown.razor.cs index 61d0c09f0f9..69848af544a 100644 --- a/src/BootstrapBlazor/Components/Dropdown/Dropdown.razor.cs +++ b/src/BootstrapBlazor/Components/Dropdown/Dropdown.razor.cs @@ -68,7 +68,7 @@ public partial class Dropdown /// /// protected string? DisableItem(SelectedItem item) => CssBuilder.Default("dropdown-item") - .AddClass("is-disabled", item.IsDisabled) + .AddClass("disabled", item.IsDisabled) .Build(); /// diff --git a/src/BootstrapBlazor/Components/SelectGeneric/SelectGeneric.razor b/src/BootstrapBlazor/Components/SelectGeneric/SelectGeneric.razor index f5764ae07d9..98737b6142b 100644 --- a/src/BootstrapBlazor/Components/SelectGeneric/SelectGeneric.razor +++ b/src/BootstrapBlazor/Components/SelectGeneric/SelectGeneric.razor @@ -31,15 +31,15 @@ } /// - protected override Task InvokeInitAsync() => InvokeVoidAsync("init", Id, Interop, nameof(ConfirmSelectedItem)); + protected override Task InvokeInitAsync() => InvokeVoidAsync("init", Id, Interop, new { ConfirmMethodCallback = nameof(ConfirmSelectedItem), SearchMethodCallback = nameof(TriggerOnSearch) }); /// /// 客户端回车回调方法 @@ -408,6 +408,18 @@ public async Task ConfirmSelectedItem(int index) } } + /// + /// 客户端搜索栏回调方法 + /// + /// + /// + [JSInvokable] + public async Task TriggerOnSearch(string searchText) + { + await SearchTextChanged(searchText); + StateHasChanged(); + } + /// /// 下拉框选项点击时调用此方法 /// diff --git a/test/UnitTest/Components/DropdownTest.cs b/test/UnitTest/Components/DropdownTest.cs index f2a7a4838e6..878ca416f92 100644 --- a/test/UnitTest/Components/DropdownTest.cs +++ b/test/UnitTest/Components/DropdownTest.cs @@ -233,7 +233,7 @@ public void Disabled_Ok() new("2", "Test2") }); }); - cut.Contains("
Test1
"); + cut.Contains("
Test1
"); } [Fact] diff --git a/test/UnitTest/Components/SelectGenericTest.cs b/test/UnitTest/Components/SelectGenericTest.cs index 07aeef6caa5..bc3ec32bb2e 100644 --- a/test/UnitTest/Components/SelectGenericTest.cs +++ b/test/UnitTest/Components/SelectGenericTest.cs @@ -13,13 +13,6 @@ namespace UnitTest.Components; public class SelectGenericTest : BootstrapBlazorTestBase { - [Fact] - public void SeletectedItem_Ok() - { - var item = new SelectedItem(null!, "Text"); - Assert.Equal(item.Value, string.Empty); - } - [Fact] public async Task OnSearchTextChanged_Null() { @@ -42,7 +35,7 @@ await ctx.InvokeAsync(async () => await ctx.Instance.ConfirmSelectedItem(0); // 搜索 T - ctx.Find(".search-text").Input("T"); + await ctx.Instance.TriggerOnSearch("T"); await ctx.Instance.ConfirmSelectedItem(0); }); @@ -68,9 +61,9 @@ await ctx.InvokeAsync(async () => }); }); - await ctx.InvokeAsync(() => + await ctx.InvokeAsync(async () => { - ctx.Find(".search-text").Input("T"); + await ctx.Instance.TriggerOnSearch("T"); }); cut.DoesNotContain("Test2"); } @@ -672,8 +665,7 @@ public async Task IsVirtualize_Items_Clearable_Ok() // 覆盖有搜索条件时,点击清空按钮 // 期望 UI 显示值为默认值 // 期望 下拉框为全数据 - var input = cut.Find(".search-text"); - await cut.InvokeAsync(() => input.Input("2")); + await cut.InvokeAsync(() => cut.Instance.TriggerOnSearch("2")); // 下拉框仅显示一个选项 Test2 var items = cut.FindAll(".dropdown-item"); @@ -730,8 +722,7 @@ public async Task IsVirtualize_OnQueryAsync_Clearable_Ok() // 覆盖有搜索条件时,点击清空按钮 // 期望 UI 显示值为默认值 // 期望 下拉框为全数据 - var input = cut.Find(".search-text"); - await cut.InvokeAsync(() => input.Input("2")); + await cut.InvokeAsync(() => cut.Instance.TriggerOnSearch("2")); // 下拉框仅显示一个选项 Test2 var items = cut.FindAll(".dropdown-item"); diff --git a/test/UnitTest/Components/SelectTest.cs b/test/UnitTest/Components/SelectTest.cs index e8499a8be79..da97baee2d3 100644 --- a/test/UnitTest/Components/SelectTest.cs +++ b/test/UnitTest/Components/SelectTest.cs @@ -35,7 +35,7 @@ await ctx.InvokeAsync(async () => await ctx.Instance.ConfirmSelectedItem(0); // 搜索 T - ctx.Find(".search-text").Input("T"); + await ctx.Instance.TriggerOnSearch("T"); await ctx.Instance.ConfirmSelectedItem(0); }); @@ -61,9 +61,9 @@ await ctx.InvokeAsync(async () => }); }); - await ctx.InvokeAsync(() => + await ctx.InvokeAsync(async () => { - ctx.Find(".search-text").Input("T"); + await ctx.Instance.TriggerOnSearch("T"); }); cut.DoesNotContain("Test2"); } @@ -663,7 +663,7 @@ public async Task IsVirtualize_Items_Clearable_Ok() // 期望 UI 显示值为默认值 // 期望 下拉框为全数据 var input = cut.Find(".search-text"); - await cut.InvokeAsync(() => input.Input("2")); + await cut.InvokeAsync(() => cut.Instance.TriggerOnSearch("2")); // 下拉框仅显示一个选项 Test2 var items = cut.FindAll(".dropdown-item"); @@ -721,7 +721,7 @@ public async Task IsVirtualize_OnQueryAsync_Clearable_Ok() // 期望 UI 显示值为默认值 // 期望 下拉框为全数据 var input = cut.Find(".search-text"); - await cut.InvokeAsync(() => input.Input("2")); + await cut.InvokeAsync(() => cut.Instance.TriggerOnSearch("2")); // 下拉框仅显示一个选项 Test2 var items = cut.FindAll(".dropdown-item");