How to Prevent Node When Clicking Button In HTML in Angular Diagram?
In this article, you can learn how to prevent a node from being selected when clicking a button in HTML within an Angular Diagram. In Syncfusion® Angular Diagram, nodes can contain HTML templates with interactive elements, such as buttons. When clicking these buttons, you may want to prevent the node from being selected. This can be done by handling the selectionChange event, which is triggered whenever a selection attempt is made.
This guide demonstrates how to prevent node selection when clicking a button within the node’s HTML template by checking if the active element is the button and canceling the selection process by setting args.cancel to true.
// Function to handle the selectionChange event
public selectionChange(args: ISelectionChangeEventArgs): void {
// Check if the currently focused element is the button inside the node
if (document.activeElement && document.activeElement.id === 'buttonInsideNode') {
// Cancel the node selection
args.cancel = true;
}
}
You can find a working example of this implementation on StackBlitz in the provided link: Click here for sample
Conclusion:
I hope you enjoyed learning how to prevent node selection while mouse clicking on an HTML template button in the Angular Diagram. You can refer to our Angular Diagram feature tour page to learn about its other groundbreaking feature representations and documentation, and how to quickly get started with configuration specifications. You can also explore our Angular Diagram example to understand how to create 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 explore our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, BoldDesk Support, or feedback portal. We are always happy to assist you!