diff --git a/src/BootstrapBlazor/BootstrapBlazor.csproj b/src/BootstrapBlazor/BootstrapBlazor.csproj index 7533b66be05..1d6ae9ca8d3 100644 --- a/src/BootstrapBlazor/BootstrapBlazor.csproj +++ b/src/BootstrapBlazor/BootstrapBlazor.csproj @@ -1,7 +1,7 @@ - 8.2.5 + 8.2.6-beta01 diff --git a/src/BootstrapBlazor/Components/Select/Select.razor.cs b/src/BootstrapBlazor/Components/Select/Select.razor.cs index d93c442bf89..20c789093f9 100644 --- a/src/BootstrapBlazor/Components/Select/Select.razor.cs +++ b/src/BootstrapBlazor/Components/Select/Select.razor.cs @@ -107,6 +107,13 @@ public partial class Select : ISelect [Parameter] public bool IsEditable { get; set; } + /// + /// 获得/设置 选项输入更新后回调方法 默认 null + /// + /// 设置 后生效 + [Parameter] + public Func? OnInputChangedCallback { get; set; } + /// /// 获得/设置 无搜索结果时显示文字 /// @@ -436,7 +443,7 @@ private void OnClearValue() CurrentValue = default; } - private void OnChange(ChangeEventArgs args) + private async Task OnChange(ChangeEventArgs args) { if (args.Value is string v) { @@ -451,6 +458,11 @@ private void OnChange(ChangeEventArgs args) Items = items; } CurrentValueAsString = v; + + if (OnInputChangedCallback != null) + { + await OnInputChangedCallback(v); + } } } } diff --git a/test/UnitTest/Components/SelectTest.cs b/test/UnitTest/Components/SelectTest.cs index 3a593fc6a18..05b7bd1b494 100644 --- a/test/UnitTest/Components/SelectTest.cs +++ b/test/UnitTest/Components/SelectTest.cs @@ -817,9 +817,15 @@ public async Task IsEditable_Ok() var input = cut.Find(".form-select"); Assert.True(input.IsReadOnly()); + var updated = false; cut.SetParametersAndRender(pb => { pb.Add(a => a.IsEditable, true); + pb.Add(a => a.OnInputChangedCallback, v => + { + updated = true; + return Task.CompletedTask; + }); }); Assert.False(input.IsReadOnly()); @@ -828,5 +834,6 @@ await cut.InvokeAsync(() => input.Change("Test3"); }); Assert.Equal("Test3", cut.Instance.Value); + Assert.True(updated); } }