Skip to content
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

Add IsMenuShown to BlazorContextMenuService #128

Merged
merged 1 commit into from
Nov 29, 2022

Conversation

adamashton
Copy link
Contributor

@adamashton adamashton commented Nov 29, 2022

Overview

This came about because I have a button that shows the Menu via a button click.

<button @onclick="ToggleMenu">Show Menu</button>

with

private async Task ToggleMenu()
{
  if (menuIsShown)
  {
      await BlazorContextMenuService.HideMenu("menu");
  }
  else
  {
      await BlazorContextMenuService.ShowMenu("menu", (int) mouseEventArgs.ClientX, (int) mouseEventArgs.ClientY);
  }
  menuIsShown = !menuIsShown;
}  

My local variable menuIsShown cannot be used because the Menu is set to AutoHide. I need another way of determining if the menu is shown. E.g.,

if (BlazorContextMenuService.IsMenuShown("menu"))
{
    await BlazorContextMenuService.HideMenu("menu");
}
else
{
    await BlazorContextMenuService.ShowMenu("menu", (int) mouseEventArgs.ClientX, mouseEventArgs.ClientY);
}

Tests

I could not get the tests to run but I have attempted to write some.

@stavroskasidis
Copy link
Owner

Wow, thank you for contributing. I will merge and push a new version

@stavroskasidis stavroskasidis merged commit de981f9 into stavroskasidis:develop Nov 29, 2022
@yeganehaym
Copy link

the last version on nuget doesnt have any methos in "blazorContextMenuService" ?
i had to install 1.16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants