BlazorContextMenu icon indicating copy to clipboard operation
BlazorContextMenu copied to clipboard

Prevent Show of ContextMenu based on a bool value

Open WoistdasNiveau opened this issue 10 months ago • 1 comments

Is your feature request related to a problem? Please describe. I want so be able to not show the Context Menu at all the na specific bool value is set to true such that right Click shows either default behavior or nothing, however, i could to find a way in the Documentation and the disabled property does not work.

Describe the solution you'd like If boolean value is set to true right click should either show the default behavior or do nothing at all.

WoistdasNiveau avatar Jan 11 '25 14:01 WoistdasNiveau

Hello.

You could use the OnAppearing event of the ContextMenu and set the PreventShow property in the MenuAppearingEventArgs to true to prevent the menu from appearing or you could not render the ContextMenuTrigger at all when the condition you need is met.

stavroskasidis avatar Jan 11 '25 15:01 stavroskasidis

So, this is the method I tried to use to prevent showing the context menu. It's very intuitive and it works as I expected, but with the console open I'm noticing an exception if I set PreventShow to false.

There's not much for me to go on because all I get is Uncaught (in promise) coming out of blazorContextMenu.min.js (line:1, col:1681).

CSNathanWoods avatar Jun 29 '25 19:06 CSNathanWoods