Clone node inside section positioning wrong

I’m trying to clone a node and position it under the original node and it works fine until the node is inside a section. Do you have any guidance on how I can make sure the node position is relative to the parent?

Example code below

    // Clone the selected node so we can swap the tokens
    const clonedNode = selectedNode.clone();

    // Create Frame node to act as a skeleton
    const frame = figma.createFrame();
    frame.y = selectedNode.y + selectedNode.height + 40;
    frame.x = selectedNode.x;

Your code says otherwise: create a new frame and position it below the selected object. I don’t see you changing clonedNode coordinates.

If you want to change the coordinates of the created frame relative to the parent of the selected object, you need to insert the frame into that parent and then change the X, Y value.