diff --git a/src/BootstrapBlazor/BootstrapBlazor.csproj b/src/BootstrapBlazor/BootstrapBlazor.csproj index 6bf9e1e245d..050b7a3e16b 100644 --- a/src/BootstrapBlazor/BootstrapBlazor.csproj +++ b/src/BootstrapBlazor/BootstrapBlazor.csproj @@ -1,7 +1,7 @@ - 8.9.2-beta06 + 8.9.2-beta07 diff --git a/src/BootstrapBlazor/Components/Select/Select.razor.cs b/src/BootstrapBlazor/Components/Select/Select.razor.cs index d1dbf3944c7..9e421165b97 100644 --- a/src/BootstrapBlazor/Components/Select/Select.razor.cs +++ b/src/BootstrapBlazor/Components/Select/Select.razor.cs @@ -432,7 +432,12 @@ private async Task OnClearValue() { await OnClearAsync(); } - CurrentValue = default; + + var item = DataSource.FirstOrDefault(); + if (item != null) + { + await SelectedItemChanged(item); + } } private string? ReadonlyString => IsEditable ? null : "readonly"; diff --git a/test/UnitTest/Components/SelectTest.cs b/test/UnitTest/Components/SelectTest.cs index 601c867822f..3feae3fec5b 100644 --- a/test/UnitTest/Components/SelectTest.cs +++ b/test/UnitTest/Components/SelectTest.cs @@ -97,7 +97,7 @@ public void IsClearable_Ok() new("2", "Test2"), new("3", "Test3") }); - pb.Add(a => a.Value, ""); + pb.Add(a => a.Value, "2"); pb.Add(a => a.OnValueChanged, v => { val = v; @@ -106,7 +106,7 @@ public void IsClearable_Ok() }); var clearButton = cut.Find(".clear-icon"); cut.InvokeAsync(() => clearButton.Click()); - Assert.Null(val); + Assert.Empty(val); // 提高代码覆盖率 var select = cut;