Skip to content

Commit 77bb3ef

Browse files
authored
feat(ValidateForm): add UnregisterAsyncSubmitButton method (#7889)
* feat: 增加 UnregisterAsyncSubmitButton 方法 * revert: 撤销对 ButtonBase 的更改
1 parent 20e7174 commit 77bb3ef

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/BootstrapBlazor/Components/Button/ButtonBase.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// See the LICENSE file in the project root for more information.
44
// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone
55

6+
using Microsoft.AspNetCore.Components.Web;
7+
68
namespace BootstrapBlazor.Components;
79

810
/// <summary>
@@ -63,7 +65,7 @@ public abstract class ButtonBase : TooltipWrapperBase
6365
/// <para lang="en">Gets or sets the OnClick event</para>
6466
/// </summary>
6567
[Parameter]
66-
public EventCallback OnClick { get; set; }
68+
public EventCallback<MouseEventArgs> OnClick { get; set; }
6769

6870
/// <summary>
6971
/// <para lang="zh">获得/设置 OnClick 事件不刷新父组件</para>
@@ -334,7 +336,7 @@ protected override async ValueTask DisposeAsync(bool disposing)
334336
{
335337
if (OnClick.HasDelegate)
336338
{
337-
OnClick = EventCallback.Empty;
339+
OnClick = EventCallback<MouseEventArgs>.Empty;
338340
}
339341

340342
if (IsAsync && ValidateForm != null)

src/BootstrapBlazor/Components/ValidateForm/ValidateForm.razor.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,16 @@ internal void RegisterAsyncSubmitButton(ButtonBase button)
577577
AsyncSubmitButtons.Add(button);
578578
}
579579

580+
/// <summary>
581+
/// <para lang="zh">注销提交按钮</para>
582+
/// <para lang="en">Unregisters a submit button</para>
583+
/// </summary>
584+
/// <param name="button"></param>
585+
internal void UnregisterAsyncSubmitButton(ButtonBase button)
586+
{
587+
AsyncSubmitButtons.Remove(button);
588+
}
589+
580590
private TaskCompletionSource<bool>? _tcs;
581591

582592
private async Task OnValidSubmitForm(EditContext context)

0 commit comments

Comments
 (0)