diff --git a/src/BootstrapBlazor/Components/AutoComplete/AutoComplete.razor.cs b/src/BootstrapBlazor/Components/AutoComplete/AutoComplete.razor.cs index 151b05a3f2d..6dd97e780c6 100644 --- a/src/BootstrapBlazor/Components/AutoComplete/AutoComplete.razor.cs +++ b/src/BootstrapBlazor/Components/AutoComplete/AutoComplete.razor.cs @@ -60,12 +60,6 @@ public partial class AutoComplete [Parameter] public bool OnFocusFilter { get; set; } - /// - /// 获得/设置 失去焦点回调方法 默认 null - /// - [Parameter] - public Func? OnBlurAsync { get; set; } - /// /// 获得/设置 匹配时是否忽略大小写,默认为 true /// @@ -150,9 +144,9 @@ protected override void OnParametersSet() } /// - /// OnBlur 方法 + /// /// - protected virtual async Task OnBlur() + protected override async Task OnBlur() { CurrentSelectedItem = ""; IsShown = false; diff --git a/src/BootstrapBlazor/Components/AutoFill/AutoFill.razor.cs b/src/BootstrapBlazor/Components/AutoFill/AutoFill.razor.cs index ea4c1eed9c1..5e821b35da8 100644 --- a/src/BootstrapBlazor/Components/AutoFill/AutoFill.razor.cs +++ b/src/BootstrapBlazor/Components/AutoFill/AutoFill.razor.cs @@ -139,9 +139,9 @@ protected override void OnParametersSet() } /// - /// OnBlur 方法 + /// /// - protected async Task OnBlur() + protected override async Task OnBlur() { _isShown = false; if (OnSelectedItemChanged != null && ActiveSelectedItem != null) @@ -149,6 +149,11 @@ protected async Task OnBlur() await OnSelectedItemChanged(ActiveSelectedItem); ActiveSelectedItem = default; } + + if (OnBlurAsync != null) + { + await OnBlurAsync(Value); + } } /// diff --git a/src/BootstrapBlazor/Components/Input/BootstrapInput.razor.cs b/src/BootstrapBlazor/Components/Input/BootstrapInput.razor.cs index 633bd8252cb..22d872b6409 100644 --- a/src/BootstrapBlazor/Components/Input/BootstrapInput.razor.cs +++ b/src/BootstrapBlazor/Components/Input/BootstrapInput.razor.cs @@ -22,12 +22,6 @@ public partial class BootstrapInput [Parameter] public bool AutoSetDefaultWhenNull { get; set; } - /// - /// 获得/设置 失去焦点回调方法 默认 null - /// - [Parameter] - public Func? OnBlurAsync { get; set; } - private string? ReadonlyString => Readonly ? "true" : null; /// @@ -53,15 +47,4 @@ protected override bool TryParseValueFromString(string value, [MaybeNullWhen(fal } return ret; } - - /// - /// OnBlur 方法 - /// - protected virtual async Task OnBlur() - { - if (OnBlurAsync != null) - { - await OnBlurAsync(Value); - } - } } diff --git a/src/BootstrapBlazor/Components/Input/BootstrapInputBase.cs b/src/BootstrapBlazor/Components/Input/BootstrapInputBase.cs index 8a2c728dc48..123e5a14820 100644 --- a/src/BootstrapBlazor/Components/Input/BootstrapInputBase.cs +++ b/src/BootstrapBlazor/Components/Input/BootstrapInputBase.cs @@ -84,6 +84,12 @@ public abstract class BootstrapInputBase : ValidateBase [Parameter] public bool IsTrim { get; set; } + /// + /// 获得/设置 失去焦点回调方法 默认 null + /// + [Parameter] + public Func? OnBlurAsync { get; set; } + [CascadingParameter] private Modal? Modal { get; set; } @@ -191,6 +197,17 @@ protected override async Task OnAfterRenderAsync(bool firstRender) /// protected override bool TryParseValueFromString(string value, [MaybeNullWhen(false)] out TValue result, out string? validationErrorMessage) => base.TryParseValueFromString(IsTrim ? value.Trim() : value, out result, out validationErrorMessage); + /// + /// OnBlur 方法 + /// + protected virtual async Task OnBlur() + { + if (OnBlurAsync != null) + { + await OnBlurAsync(Value); + } + } + /// /// 客户端 EnterCallback 回调方法 /// diff --git a/src/BootstrapBlazor/Components/Input/FloatingLabel.razor b/src/BootstrapBlazor/Components/Input/FloatingLabel.razor index 784a19e84dd..6ffa180d6cd 100644 --- a/src/BootstrapBlazor/Components/Input/FloatingLabel.razor +++ b/src/BootstrapBlazor/Components/Input/FloatingLabel.razor @@ -3,6 +3,6 @@ @inherits BootstrapInputBase
- +
diff --git a/src/BootstrapBlazor/Components/InputNumber/BootstrapInputNumber.razor.cs b/src/BootstrapBlazor/Components/InputNumber/BootstrapInputNumber.razor.cs index 643f5dcafd7..78095ad545d 100644 --- a/src/BootstrapBlazor/Components/InputNumber/BootstrapInputNumber.razor.cs +++ b/src/BootstrapBlazor/Components/InputNumber/BootstrapInputNumber.razor.cs @@ -83,12 +83,6 @@ public partial class BootstrapInputNumber [Parameter] public string? PlusIcon { get; set; } - /// - /// 获得/设置 失去焦点回调方法 默认 null - /// - [Parameter] - public Func? OnBlurAsync { get; set; } - [Inject] [NotNull] private IStringLocalizer>? Localizer { get; set; } @@ -268,10 +262,10 @@ private async Task OnClickInc() } /// - /// 失去焦点是触发此方法 + /// /// /// - private async Task OnBlur() + protected override async Task OnBlur() { if (!PreviousParsingAttemptFailed) { diff --git a/src/BootstrapBlazor/Components/Textarea/Textarea.razor.cs b/src/BootstrapBlazor/Components/Textarea/Textarea.razor.cs index 7cf89002614..4f192d7547b 100644 --- a/src/BootstrapBlazor/Components/Textarea/Textarea.razor.cs +++ b/src/BootstrapBlazor/Components/Textarea/Textarea.razor.cs @@ -34,12 +34,6 @@ public partial class Textarea [Parameter] public bool IsAutoScroll { get; set; } - /// - /// 获得/设置 失去焦点回调方法 默认 null - /// - [Parameter] - public Func? OnBlurAsync { get; set; } - /// /// 获得 客户端是否自动滚屏标识 /// @@ -59,15 +53,4 @@ protected override async Task OnAfterRenderAsync(bool firstRender) await InvokeVoidAsync("execute", Id, "update"); } } - - /// - /// OnBlur 方法 - /// - protected virtual async Task OnBlur() - { - if (OnBlurAsync != null) - { - await OnBlurAsync(Value); - } - } }