Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions src/BootstrapBlazor/Components/Button/ButtonBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// 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 @@ -63,7 +65,7 @@ public abstract class ButtonBase : TooltipWrapperBase
/// <para lang="en">Gets or sets the OnClick event</para>
/// </summary>
[Parameter]
public EventCallback OnClick { get; set; }
public EventCallback<MouseEventArgs> 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 ButtonBase.OnClick from untyped EventCallback to EventCallback is a public API breaking change and appears unrelated to the ValidateForm unregister feature. This will break consumers that set OnClick from C# (or via reflection/parameter dictionaries) expecting EventCallback. Consider keeping the existing EventCallback OnClick for compatibility (or adding a new typed callback alongside it / marking the old one obsolete) and update release notes accordingly if the breaking change is intended.

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

Copilot uses AI. Check for mistakes.

/// <summary>
/// <para lang="zh">获得/设置 OnClick 事件不刷新父组件</para>
Expand Down Expand Up @@ -334,7 +336,7 @@ protected override async ValueTask DisposeAsync(bool disposing)
{
if (OnClick.HasDelegate)
{
OnClick = EventCallback.Empty;
OnClick = EventCallback<MouseEventArgs>.Empty;
}

if (IsAsync && ValidateForm != null)
Expand Down
10 changes: 10 additions & 0 deletions src/BootstrapBlazor/Components/ValidateForm/ValidateForm.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,16 @@ internal void RegisterAsyncSubmitButton(ButtonBase button)
AsyncSubmitButtons.Add(button);
}

/// <summary>
/// <para lang="zh">注销提交按钮</para>
/// <para lang="en">Unregisters a submit button</para>
/// </summary>
/// <param name="button"></param>
internal void UnregisterAsyncSubmitButton(ButtonBase button)
{
AsyncSubmitButtons.Remove(button);
}
Comment on lines +585 to +588
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.

UnregisterAsyncSubmitButton mutates AsyncSubmitButtons while OnValidSubmitForm/OnInvalidSubmitForm iterate that same list across multiple awaits. If an async submit button is disposed/removed while a submit callback is awaiting, this can trigger 'Collection was modified' exceptions during the subsequent foreach loops. To make this robust, consider iterating over a snapshot (e.g., ToArray()) or otherwise guarding list access during submit processing.

Copilot uses AI. Check for mistakes.

private TaskCompletionSource<bool>? _tcs;

private async Task OnValidSubmitForm(EditContext context)
Expand Down
Loading