-
-
Notifications
You must be signed in to change notification settings - Fork 381
feat(Button): add reset OnClick logic #7887
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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> | ||
|
|
@@ -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; } | ||
|
|
||
| /// <summary> | ||
| /// <para lang="zh">获得/设置 OnClick 事件不刷新父组件</para> | ||
|
|
@@ -206,8 +204,7 @@ | |
| } | ||
|
|
||
| /// <summary> | ||
| /// <para lang="zh">OnParametersSet 方法</para> | ||
| /// <para lang="en">OnParametersSet method</para> | ||
| /// <inheritdoc/> | ||
| /// </summary> | ||
| protected override void OnParametersSet() | ||
| { | ||
|
|
@@ -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) | ||
|
|
@@ -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
|
||
| } | ||
|
Comment on lines
+335
to
+343
|
||
|
|
||
| await RemoveTooltip(); | ||
| } | ||
| await base.DisposeAsync(disposing); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing
OnClickfromEventCallback<MouseEventArgs>to non-genericEventCallbackis a breaking API change and will also break existing usages inside this repo that bind parameterized handlers (e.g.,OnClick="@(e => ...)"insrc/BootstrapBlazor.Server/Components/Components/WinButton.razor:1and tests liketest/UnitTest/Components/ButtonTest.cs:163). If the intent is to keep supporting click handlers that acceptMouseEventArgs, keep the generic type and (ideally) pass the actualMouseEventArgsthrough from the@onclickhandler; otherwise this needs a compatibility path (e.g., add a new parameter and obsolete the old one).