Skip to content

Commit

Permalink
[MenuButton] Fix the MenuItem OnClick used with MenuButton (#2784)
Browse files Browse the repository at this point in the history
* Fix the MenuItem OnClick used with MenuButton

* Update doc
  • Loading branch information
dvoituron authored Oct 9, 2024
1 parent 0844597 commit 41542e2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Core/Components/MenuButton/FluentMenuButton.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public partial class FluentMenuButton : FluentComponentBase

/// <summary>
/// The callback to invoke when a menu item is chosen.
/// Using this event prevents the execution of any OnClick event on an included FluentMenuItem.
/// </summary>
[Parameter]
public EventCallback<MenuChangeEventArgs> OnMenuChanged { get; set; }
Expand All @@ -92,10 +93,16 @@ private void ToggleMenu()

private async Task OnMenuChangeAsync(MenuChangeEventArgs args)
{
if (!OnMenuChanged.HasDelegate)
{
return;
}

if (args is not null && args.Id is not null)
{
await OnMenuChanged.InvokeAsync(args);
}

_visible = false;
}

Expand Down

0 comments on commit 41542e2

Please sign in to comment.