Graphin icon indicating copy to clipboard operation
Graphin copied to clipboard

feat: ContextMenu component will now handle multiple bindtypes for a single context menu.

Open gazzamc opened this issue 3 years ago • 1 comments

In the initial implementation there was no way of binding a single context menu to multiple bindings, this will solve this issue while maintaining the original implementation.

bindtype prop will now accept an array of the bindtypes, and will still accept a singular bindtype as per the original.

Multiple:

<ContextMenu bindType={["canvas", "node", "edge"]}>
    // code
</ContextMenu>

Single:

<ContextMenu bindType={"canvas"}>
    // code
</ContextMenu>

When calling handleClose(), it only needs to be done for the one bindtype as they share the same state to prevent multiple context menus opening.

eg.

graphin.contextmenu.canvas.handleClose();

https://user-images.githubusercontent.com/7975925/166912128-734ca4d7-34d2-4ed6-8919-8704100e499d.mp4

gazzamc avatar May 05 '22 11:05 gazzamc

@gazzamc The NodeContextMenu and CanvasContextMenu are divided into two components, which is beneficial to the single responsibility of the components, so it is not suitable for one ContextMenu to bind multiple types at the same time. But thank you very much for your feedback on how the two different types of ContextMenu are mutually exclusive in interaction (as shown in your DEMO), which we will implement in this place later.

pomelo-nwu avatar May 10 '22 01:05 pomelo-nwu