-
-
Notifications
You must be signed in to change notification settings - Fork 365
feat(Dropdown): add OnClick event callback #5319
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8f52842
feat: 增加 OnClick 回调方法
ArgoZhang 5f61066
feat: 增加 OnClickWithoutRender 回调方法
ArgoZhang 91b4840
feat: 增加点击事件委托方法实现
ArgoZhang a19e2cd
feat: 更改为 DynamicElement 组件
ArgoZhang f9d9922
doc: 更新文档示例
ArgoZhang c0610be
doc: 更新文档
ArgoZhang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,8 @@ | |
| // See the LICENSE file in the project root for more information. | ||
| // Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone | ||
|
|
||
| using Microsoft.AspNetCore.Components.Web; | ||
|
|
||
| namespace BootstrapBlazor.Components; | ||
|
|
||
| /// <summary> | ||
|
|
@@ -102,6 +104,18 @@ public partial class Dropdown<TValue> | |
| [Parameter] | ||
| public bool ShowSplit { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// 获得/设置 OnClick 事件 | ||
| /// </summary> | ||
| [Parameter] | ||
| public EventCallback<MouseEventArgs> OnClick { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// 获得/设置 OnClick 事件不刷新父组件 | ||
| /// </summary> | ||
| [Parameter] | ||
| public Func<Task>? OnClickWithoutRender { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// 获得/设置 获取菜单对齐方式 默认 none 未设置 | ||
| /// </summary> | ||
|
|
@@ -203,4 +217,16 @@ protected async Task OnItemClick(SelectedItem item) | |
| } | ||
|
|
||
| private string? ButtonText => IsFixedButtonText ? FixedButtonText : SelectedItem?.Text; | ||
|
|
||
| private async Task OnClickButton() | ||
| { | ||
| if (OnClickWithoutRender != null) | ||
| { | ||
| await OnClickWithoutRender(); | ||
| } | ||
| if (OnClick.HasDelegate) | ||
| { | ||
| await OnClick.InvokeAsync(); | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
issue: Event callback handler signature may be missing MouseEventArgs parameter.
Since the OnClick parameter is of type EventCallback, consider updating OnClickButton to accept a MouseEventArgs parameter (e.g. OnClickButton(MouseEventArgs e)) and passing it to OnClick.InvokeAsync(e). This ensures that any event data provided by the underlying click event is not lost.