Skip to content

Add subflow + layout example #3

@fum4

Description

@fum4

Hello,

I'm having a hard time implementing auto layouting in the context of subflows. From what I understand the demo app should be able to handle this, but I can't manage to make a working example.

This is my workflow structure (using parentNode as we are using reactflow@11):

{
  "nodes": [
    {
      "id": "A",
      "type": "base"
    },
    {
      "id": "B",
      "type": "base"
    },
    {
      "id": "C",
      "type": "base",
      "parentNode": "A",
      "extent": "parent"
    },
    {
      "id": "D",
      "type": "base",
      "parentNode": "A",
      "extent": "parent"
    },
    {
      "id": "E",
      "type": "base",
      "parentNode": "A",
      "extent": "parent"
    },
    {
      "id": "F",
      "type": "base"
    }
  ],
  "edges": [
    {
      "id": "A#B",
      "source": "A",
      "target": "B",
      "sourceHandle": "A#source",
      "targetHandle": "B#target"
    },
    {
      "id": "B#F",
      "source": "B",
      "target": "F",
      "sourceHandle": "B#source",
      "targetHandle": "F#target"
    },
    {
      "id": "C#D",
      "source": "C",
      "target": "D",
      "sourceHandle": "C#source",
      "targetHandle": "D#target"
    },
    {
      "id": "D#E",
      "source": "D",
      "target": "E",
      "sourceHandle": "D#source",
      "targetHandle": "E#target"
    }
  ]
}

This is what react flow renders. As you can see the 3 nodes that should be part of the subflow are not rendered inside the parent node:

Screenshot 2024-11-11 at 15 24 50

I tried with all available layout algorithms and the results look similar. Not sure what I'm missing but I appreciate any help 🙏

Thanks a lot!

P.S. I think this might be very useful as from what I see there are a lot of people having a hard time implementing this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions