Skip to content

Commit c6f8ad8

Browse files
committed
refactor: 增加 OnClick 重置逻辑
1 parent f284f44 commit c6f8ad8

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

src/BootstrapBlazor/Components/Button/ButtonBase.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
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-
86
namespace BootstrapBlazor.Components;
97

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

7068
/// <summary>
7169
/// <para lang="zh">获得/设置 OnClick 事件不刷新父组件</para>
@@ -334,6 +332,16 @@ protected override async ValueTask DisposeAsync(bool disposing)
334332
{
335333
if (disposing)
336334
{
335+
if (OnClick.HasDelegate)
336+
{
337+
OnClick = EventCallback.Empty;
338+
}
339+
340+
if (IsAsync && ValidateForm != null)
341+
{
342+
ValidateForm.UnregisterAsyncSubmitButton(this);
343+
}
344+
337345
await RemoveTooltip();
338346
}
339347
await base.DisposeAsync(disposing);

0 commit comments

Comments
 (0)