mirror of
https://github.com/n8n-io/n8n.git
synced 2026-08-30 18:01:23 +08:00
fix(editor): Snap tidy-up node positions to grid (#30455)
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+1
-1
@@ -135,7 +135,7 @@ exports[`useCanvasLayout > should layout a workflow with sticky notes 1`] = `
|
||||
},
|
||||
{
|
||||
"id": "sticky",
|
||||
"x": 134,
|
||||
"x": 128,
|
||||
"y": -240,
|
||||
},
|
||||
],
|
||||
|
||||
+11
-7
@@ -565,15 +565,19 @@ export function useCanvasLayout(canvasId: string, isEmbeddedNdvActive: ComputedR
|
||||
})
|
||||
.filter(isPresent);
|
||||
|
||||
const snapToGrid = (value: number) => Math.round(value / GRID_SIZE) * GRID_SIZE;
|
||||
|
||||
const finalNodes = positionedNodes.concat(positionedStickies).map(({ id, boundingBox }) => {
|
||||
return {
|
||||
id,
|
||||
x: snapToGrid(boundingBox.x - anchor.x),
|
||||
y: snapToGrid(boundingBox.y - anchor.y),
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
boundingBox: boundingBoxAfter,
|
||||
nodes: positionedNodes.concat(positionedStickies).map(({ id, boundingBox }) => {
|
||||
return {
|
||||
id,
|
||||
x: boundingBox.x - anchor.x,
|
||||
y: boundingBox.y - anchor.y,
|
||||
};
|
||||
}),
|
||||
nodes: finalNodes,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user