diff --git a/src/editor/js/components/editor.tsx b/src/editor/js/components/editor.tsx index 547d95a7d5d2e4ec4e73b613c72c076d4adf0e23..96abf382d5d08ea46db682dec31fa96138c8e061 100644 --- a/src/editor/js/components/editor.tsx +++ b/src/editor/js/components/editor.tsx @@ -144,6 +144,20 @@ export class Editor extends React.PureComponent<propTypes, stateTypes> { * @param event Click event. */ 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(); newNode.label = "Unnamed";