🙋 SDK Version
@flowgram.ai/free-layout-core: 0.1.8
📌 Layout
Free layout
💻 Environment
- Operation System: Linux 5.15 (WSL)
- Node.js: (Please fill in your version)
- Other: flowgram.ai repository
📝 Question Description
Bug Summary
When loading initial data using fromJSON(), lines connecting nodes fail to render if the node's meta.size and wrapperStyle have the same width/height values. This bug only occurs during initial data loading; drag-and-drop and manual connections work correctly.
Steps to Reproduce
- Create a custom node with
meta.size and wrapperStyle having the same width/height values:
meta: {
size: {
width: 80,
height: 80,
},
wrapperStyle: {
width: '80px',
height: '80px',
// ... other styles
},
}
- Load initial data with nodes connected by edges:
{
"nodes": [
{ "id": "start", "type": "custom-start", "meta": { "position": { "x": 40, "y": 0 } } },
{ "id": "variable", "type": "custom-variable", "meta": { "position": { "x": 220, "y": 0 } } },
{ "id": "end", "type": "custom-end", "meta": { "position": { "x": 400, "y": 0 } } }
],
"edges": [
{ "sourceNodeID": "start", "targetNodeID": "variable" },
{ "sourceNodeID": "variable", "targetNodeID": "end" }
]
}
- Call
document.fromJSON(initialData) to load the data
- Observe that the lines connecting the nodes are not rendered
Workarounds (Not Recommended)
The bug can be temporarily avoided by:
- Removing
meta.size from the node definition, OR
- Removing
wrapperStyle.width/height from the node definition, OR
- Making the width/height values different between
meta.size and wrapperStyle
Temporary Workaround (Not Recommended)
The following workaround works but is not a proper solution:
// In workflow-line-render-data.ts update method
public update(): void {
this.syncContributions();
// const oldVersion = this.data.version;
this.updatePosition();
// const newVersion = this.data.version;
// if (oldVersion === newVersion) {
// return; // Early return prevents update
// }
// this.data.version = newVersion;
this.currentLine?.update({
fromPos: this.data.position.from,
toPos: this.data.position.to,
});
}
// In workflow-document.ts fromJSON method
setTimeout(() => {
this.linesManager.forceUpdate();
}, 100);
Additional Notes
- This bug only affects initial data loading via
fromJSON()
- Drag-and-drop and manual connections work correctly because the DOM is already rendered when lines are created
- The issue is related to the timing of DOM rendering vs. line position calculation
🙋 SDK Version
@flowgram.ai/free-layout-core: 0.1.8
📌 Layout
Free layout
💻 Environment
📝 Question Description
Bug Summary
When loading initial data using
fromJSON(), lines connecting nodes fail to render if the node'smeta.sizeandwrapperStylehave the same width/height values. This bug only occurs during initial data loading; drag-and-drop and manual connections work correctly.Steps to Reproduce
meta.sizeandwrapperStylehaving the same width/height values:document.fromJSON(initialData)to load the dataWorkarounds (Not Recommended)
The bug can be temporarily avoided by:
meta.sizefrom the node definition, ORwrapperStyle.width/heightfrom the node definition, ORmeta.sizeandwrapperStyleTemporary Workaround (Not Recommended)
The following workaround works but is not a proper solution:
Additional Notes
fromJSON()