Skip to content
Snippets Groups Projects
Commit 917ec8e7 authored by Maximilian Giller's avatar Maximilian Giller :squid:
Browse files

Implements special case handling to avoid incorrectly triggered background click event

parent e690cc3f
No related branches found
No related tags found
1 merge request!2Implemented editor in the react framework
Pipeline #56893 passed
...@@ -144,6 +144,20 @@ export class Editor extends React.PureComponent<propTypes, stateTypes> { ...@@ -144,6 +144,20 @@ export class Editor extends React.PureComponent<propTypes, stateTypes> {
* @param event Click event. * @param event Click event.
*/ */
private handleBackgroundClick(event: any, position: clickPosition) { private handleBackgroundClick(event: any, position: clickPosition) {
// Is there really no node there? Trying to prevent small error, where this event is triggered, even if there is a node.
const placeholderNode: Node = {
id: undefined,
x: position.graph.x,
y: position.graph.y,
} as unknown as Node;
const nearestNode =
this.state.graph.getClosestOtherNode(placeholderNode);
if (nearestNode !== undefined && nearestNode.distance < 4) {
console.log("Saved node click event");
this.handleNodeClick(nearestNode.node);
return;
}
const newNode = new Node(); const newNode = new Node();
newNode.label = "Unnamed"; newNode.label = "Unnamed";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment