When clicking on a blank area of the diagram, a node gets selected. If the diagram is not in focus or outside the viewport range, the click event brings the focus back to the diagram, causing the scroll bar and diagram canvas to update. This leads to the node being moved to the position where the mouse was initially clicked and selected.