Skip to content

Commit fa2f6e2

Browse files
committed
feat(BootstrapInput): add OnBlurAsync parameter
1 parent dcdf40d commit fa2f6e2

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/BootstrapBlazor/Components/Input/BootstrapInput.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
<BootstrapLabel required="@Required" for="@Id" ShowLabelTooltip="ShowLabelTooltip" Value="@DisplayText" />
88
}
99

10-
<input @attributes="@AdditionalAttributes" type="@Type" placeholder="@PlaceHolder" id="@Id" readonly="@ReadonlyString" class="@ClassName" disabled="@Disabled" @bind-value="CurrentValueAsString" @bind-value:event="@EventString" @ref="FocusElement" />
10+
<input @attributes="@AdditionalAttributes" type="@Type" placeholder="@PlaceHolder" id="@Id" readonly="@ReadonlyString" class="@ClassName" disabled="@Disabled" @bind-value="CurrentValueAsString" @bind-value:event="@EventString" @onblur="@OnBlur" @ref="FocusElement" />

src/BootstrapBlazor/Components/Input/BootstrapInput.razor.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ public partial class BootstrapInput<TValue>
2222
[Parameter]
2323
public bool AutoSetDefaultWhenNull { get; set; }
2424

25+
/// <summary>
26+
/// 获得/设置 失去焦点回调方法 默认 null
27+
/// </summary>
28+
[Parameter]
29+
public Func<TValue, Task>? OnBlurAsync { get; set; }
30+
2531
private string? ReadonlyString => Readonly ? "true" : null;
2632

2733
/// <summary>
@@ -47,4 +53,15 @@ protected override bool TryParseValueFromString(string value, [MaybeNullWhen(fal
4753
}
4854
return ret;
4955
}
56+
57+
/// <summary>
58+
/// OnBlur 方法
59+
/// </summary>
60+
protected virtual async Task OnBlur()
61+
{
62+
if (OnBlurAsync != null)
63+
{
64+
await OnBlurAsync(Value);
65+
}
66+
}
5067
}

0 commit comments

Comments
 (0)