DiagramContextMenu contextMenuClick do not appear to work properly

I am following example listed at  Context Menu in React Diagram component - Syncfusion.

I have added a small snippet listed below.  The event does not appear to be handled in the react code.  I've set-up a sample app if needed.  There appears to an issue with either the code or the sample code is not correct.  Could you please advise?


contextMenuClick: function (args) {
          //do your custom action here.
          alert('clicked') //added this
          if (args.item.id === 'delete') {
              if ((diagramInstance.selectedItems.nodes.length + diagramInstance.selectedItems.connectors.length) > 0) {
                  diagramInstance.cut();
              }
          }
      }

3 Replies

JG Jamie Gunn July 14, 2022 02:24 AM UTC

I figured out the issue. It appears that the eventhandler ( contextMenuClick ) as a property of contextMenuSettings is not valid. When reviewing other code snippets, I found adding the eventHandler (contextMenuClick) as prop directly on DiagramComponent works properly.


<DiagramComponent id="diagram" ref={diagram => (diagramInstance = diagram)} width={"100%"} height={"700px"}
contextMenuClick={this.contextMenuClick}>
<Inject services={[DiagramContextMenu]}/>
DiagramComponent>)


AR Aravind Ravi Syncfusion Team July 14, 2022 10:50 AM UTC

Hi Jamie,


Yes, we need to add contextMenuClick event directly to the diagram component. We have logged a documentation improvement task for your suggestion and We will include the documentation changes on or before the Volume 2 2022 SP1 release. We will let you know once the documentation gets refreshed in live.


Regards,

Aravind Ravi



SG Shyam G Syncfusion Team August 9, 2022 03:52 PM UTC

Hi Jamie,

We have refreshed the context menu events UG documentation in live. Please find the UG documentation link below.

https://ej2.syncfusion.com/react/documentation/diagram/context-menu/#context-menu-events

Regards,

Shyam G



Loader.
Up arrow icon