Skip to content

Svelte: Node position changes are ignored if setting parentID #5807

@CosmoMyzrailGorynych

Description

@CosmoMyzrailGorynych

What platform were you using when you found the bug?

  • Svelte Flow version: 1.6.0
  • Browser and version: Applicable to any browser. Webkit, Firefox, Chromium-based
  • OS and version: Fedora 44

Live code example

https://stackblitz.com/edit/svelte-flow-ts-p1v4ceyf?file=src%2FFlow%2Findex.svelte

Describe the Bug

I would like to implement a "group" block type which automatically moves blocks with it that are visually inside it. For that, I use parentId, intersection detection methods, and adjust positions to account relative position when using parentId, though updateNodeData.

The problem: changing the position of the node does not work if set alongside the parentId. (This is very visible with the custom node in the stackblitz demo.)

👉 Not changing parentId allows the updateNodeData method to set new positions. Additionally dirty hacks like splitting updateNodeData, using tick() or two do not work. It looks like there is an event ordering issue in Svelteflow that resets changes to nodes' position with parentId after the onnodedragstop.

Steps to reproduce the bug or issue

  1. Open the demo
  2. Drag the group node onto the custom node
  3. Observe that the coordinates of the custom node did not change despite the code that readjusts its position to relative coordinates.
  4. Dragging the node again makes it jump unpredictably.

Expected behavior

There should be a way to make dynamic parentId assignment work without special shenanigans and coordinate jumps. Setting parentId and new position must work.

Screenshots or Videos

(Putting a node into a group / putting a group over nodes produces same results)

_20260606_182818.mp4

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions