Pass triggering event on ContextMenu.Trigger to event handler
See original GitHub issueFeature request
Overview
My application includes a map, which can be right-clicked in order to bring up more details. The map is rendered with WebGL, so is basically opaque to React. I’d like to be able to use the ContextMenu component and show more details about what was right-clicked. To make this possible, it would be nice to pass the event that triggered the context menu open to a method that looks up map details.
Who does this impact? Who is this for?
This will be nice if any of the things that trigger a context menu are, well, contextual to what was right-clicked. This map example is certainly one, but something like having one context menu at a top element and using, basically, delegation to trigger different right-click menus, would be an example.
Additional context
API might look like:
<Root onOpenChange={((open: boolean, event: React.MouseEvent | React.PointerEvent))}>
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:11 (4 by maintainers)
Top Results From Across the Web
Element: contextmenu event - Web APIs | MDN
The contextmenu event fires when the user attempts to open a context menu. This event is typically triggered by clicking the right mouse ......
Read more >.contextmenu() | jQuery API Documentation
An object containing data that will be passed to the event handler. ... A function to execute each time the event is triggered....
Read more >.contextmenu() - API Manual
Description: Bind an event handler to the "contextmenu" JavaScript event, or trigger that event on an element. version added: 1.0.contextmenu( handler ).
Read more >Trigger right click using pure Javascript - Stack Overflow
Specifically, I've been able to stop a right click event from occurring on one element and in the same handler fire the context...
Read more >Documentation - jQuery contextMenu (2.x)
The show and hide events are triggered before the menu is shown or hidden. The event handlers are executed in the context of...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
We already have an
onOpenChange
that triggers when that happens so it sounds like the combination of the two is what is needed?https://codesandbox.io/s/weathered-bash-2ze4e
Yep, exactly this. In particular, using Mapbox, which gives you a method to query features at a particular point within the WebGL canvas, based on the offset from the top-left corner.
This will be a menu - basically, think of it as the same as the right-click menu on Figma. For example: right click on a stack of overlapping features and choose which feature to select.