Articles in this section

How to show or hide userhandles based on some constraints using React Diagram?

This article explains how to dynamically show or hide user handles for diagram objects using the selectionChange event.

The userhandle feature is utilized to add frequently used commands around the selector in a React Diagram. The user handle is visible only when a node with a value is selected.

To hide the user handle in a node, set the visibility of the diagram’s selection item’s user handles to false. This ensures that the user handle is not visible when a node is selected.

Here’s an example of how to set the user handle visibility to false for a node:

 selectionChange={(args) => {
     if (args.state === 'Changed' && args.type === 'Addition') {
       if (
         args.newValue[0] instanceof Node &&
         args.newValue[0].id === 'node1'
       )
         // Hides the userhandle for specified node id
         diagramInstance.selectedItems.userHandles[0].visible = false;
       else if (
         args.newValue[0] instanceof Connector &&
         args.newValue[0].id === 'connector1'
       )
         // Hides the userhandle for specified connector id
         diagramInstance.selectedItems.userHandles[0].visible = false;
       else {
         // Sets the visible property to true
         diagramInstance.selectedItems.userHandles[0].visible = true;
       }
     }
   }}

Refer to the working sample for additional details and implementation: Sample

Conclusion

We hope you enjoyed learning about how to show or hide user handles based on some constraints using React Diagram.

You can refer to our React Diagram feature tour page to learn about its other groundbreaking feature representations and documentation. You can also explore our React Diagram example to understand how to present and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our React Diagram and other components.

If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forums, BoldDesk Support, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied