Unable to move canvas node via code

I am working on my very first plugin for Obsidian - a simple way to arrange and organize nodes in canvas view. Just to test and get things working I am trying to move a selected node 50 units to the right – but it’s not working.

Its accepting the new values but the node isn’t moved in the canvas view. Below is the code I am using, but not having much luck – could someone point me in the right direction? (ie. how to mode a node, maybe even resized it, etc) I apologize if this is a basic question - I am just a beginner.

      selectedNodes.forEach((nodeId: string) => {
        const node = canvas.nodes[nodeId];
        if (node?.position) {
          console.log("Node details before move:", node);

          // Update position
          const newX = node.position.x + 50;
          const newY = node.position.y;
          node.position = { x: newX, y: newY };

          console.log(`Updated position for node ${node.id}:`, node.position);
        } else {
          console.error(`Node ${nodeId} does not support movement.`);
        }
      });

      // Trigger canvas re-render
      canvas.requestSave();
      canvas.render();

Here’s the full function:

  moveSelectedLink(canvasView: any) {
    const canvas = canvasView.canvas;

    if (!canvas) {
      console.error("Canvas not found.");
      return;
    }

    try {
      const selectedNodes = canvas.selection?.nodes || new Set();

      if (selectedNodes.size === 0) {
        console.log("No nodes selected.");
        return;
      }

      selectedNodes.forEach((nodeId: string) => {
        const node = canvas.nodes[nodeId];
        if (node?.position) {
          console.log("Node details before move:", node);

          // Update position
          const newX = node.position.x + 50;
          const newY = node.position.y;
          node.position = { x: newX, y: newY };

          console.log(`Updated position for node ${node.id}:`, node.position);
        } else {
          console.error(`Node ${nodeId} does not support movement.`);
        }
      });

      // Trigger canvas re-render
      canvas.requestSave();
      canvas.render();

      console.log("Canvas data after updates:", JSON.stringify(canvas.nodes, null, 2));
    } catch (error) {
      console.error("Error moving selected link:", error);
    }
  }