Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions src/BootstrapBlazor/Components/Button/ButtonBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
// See the LICENSE file in the project root for more information.
// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone

using Microsoft.AspNetCore.Components.Web;

namespace BootstrapBlazor.Components;

/// <summary>
Expand Down Expand Up @@ -65,7 +63,7 @@
/// <para lang="en">Gets or sets the OnClick event</para>
/// </summary>
[Parameter]
public EventCallback<MouseEventArgs> OnClick { get; set; }
public EventCallback OnClick { get; set; }
Copy link

Copilot AI Apr 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing OnClick from EventCallback<MouseEventArgs> to non-generic EventCallback is a breaking API change and will also break existing usages inside this repo that bind parameterized handlers (e.g., OnClick="@(e => ...)" in src/BootstrapBlazor.Server/Components/Components/WinButton.razor:1 and tests like test/UnitTest/Components/ButtonTest.cs:163). If the intent is to keep supporting click handlers that accept MouseEventArgs, keep the generic type and (ideally) pass the actual MouseEventArgs through from the @onclick handler; otherwise this needs a compatibility path (e.g., add a new parameter and obsolete the old one).

Suggested change
public EventCallback OnClick { get; set; }
public EventCallback<MouseEventArgs> OnClick { get; set; }

Copilot uses AI. Check for mistakes.

/// <summary>
/// <para lang="zh">获得/设置 OnClick 事件不刷新父组件</para>
Expand Down Expand Up @@ -206,8 +204,7 @@
}

/// <summary>
/// <para lang="zh">OnParametersSet 方法</para>
/// <para lang="en">OnParametersSet method</para>
/// <inheritdoc/>
/// </summary>
protected override void OnParametersSet()
{
Expand All @@ -223,8 +220,7 @@

private bool _prevDisable;
/// <summary>
/// <para lang="zh">OnAfterRenderAsync 方法</para>
/// <para lang="en">OnAfterRenderAsync method</para>
/// <inheritdoc/>
/// </summary>
/// <param name="firstRender"></param>
protected override async Task OnAfterRenderAsync(bool firstRender)
Expand Down Expand Up @@ -329,14 +325,23 @@
}

/// <summary>
/// <para lang="zh">DisposeAsyncCore 方法</para>
/// <para lang="en">DisposeAsyncCore method</para>
/// <inheritdoc/>
/// </summary>
/// <param name="disposing"></param>
protected override async ValueTask DisposeAsync(bool disposing)
{
if (disposing)
{
if (OnClick.HasDelegate)
{
OnClick = EventCallback.Empty;
}

if (IsAsync && ValidateForm != null)
{
ValidateForm.UnregisterAsyncSubmitButton(this);

Check failure on line 342 in src/BootstrapBlazor/Components/Button/ButtonBase.cs

View workflow job for this annotation

GitHub Actions / run test

'ValidateForm' does not contain a definition for 'UnregisterAsyncSubmitButton' and no accessible extension method 'UnregisterAsyncSubmitButton' accepting a first argument of type 'ValidateForm' could be found (are you missing a using directive or an assembly reference?)
}
Comment on lines +335 to +343
Copy link

Copilot AI Apr 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DisposeAsync is mutating a [Parameter] (OnClick = EventCallback.Empty). This is unconventional and easy to miss, and if the goal is to break references for GC it should be done consistently (e.g., clear OnClickWithoutRender as well) and without changing the public API shape. Consider removing this assignment entirely, or at least clearing the callback(s) using default for the existing callback type rather than introducing a new EventCallback type.

Copilot uses AI. Check for mistakes.

await RemoveTooltip();
}
await base.DisposeAsync(disposing);
Expand Down
Loading