From eb8e542ab8f402bba33ced494e237ac26d77034e Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Sun, 18 Oct 2026 23:40:33 +1100 Subject: [PATCH] fix(ui): move neighbouring columns aside when a step card opens --- ui/src/workflows/WorkflowCanvas.vue | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/ui/src/workflows/WorkflowCanvas.vue b/ui/src/workflows/WorkflowCanvas.vue index 2eb4235e4..d65eebe5e 100644 --- a/ui/src/workflows/WorkflowCanvas.vue +++ b/ui/src/workflows/WorkflowCanvas.vue @@ -125,6 +125,26 @@ function card(node: GraphNode): GraphNode { return { ...node, data: { ...data, ...extra } }; } +// An open card widens about its centre, and every column to either side moves +// out by half the growth so no neighbour sits under it. +const WIDEN = OPEN_WIDTH - NODE_WIDTH; +const holdsOpen = (node: GraphNode) => { + const open = anchor.value; + if (!open || !node.style?.width) return false; + return node.position.x <= open.position.x && node.position.x + parseFloat(String(node.style.width)) >= open.position.x + NODE_WIDTH; +}; +function spread(node: GraphNode): number { + const open = anchor.value; + if (!open) return 0; + if (node.id === open.id || holdsOpen(node)) return -WIDEN / 2; + const centre = open.position.x + NODE_WIDTH / 2; + const width = node.style?.width ? parseFloat(String(node.style.width)) : node.type === "step" ? NODE_WIDTH : 32; + const mid = node.position.x + width / 2; + // The open card's own column stays put; insertion glyphs sit near its centre. + if (Math.abs(mid - centre) < NODE_WIDTH / 2) return 0; + return mid < centre ? -WIDEN / 2 : WIDEN / 2; +} + const nodes = computed(() => { const open = anchor.value; return graph.value.nodes.map((node) => { @@ -134,16 +154,17 @@ const nodes = computed(() => { else if (node.type === "step") node = card(node); const mark = props.marks?.[node.id]; if (mark) node = { ...node, data: { ...node.data, mark } }; - const { x } = node.position; + const x = node.position.x + spread(node); const opened = (at: number) => (open && at > open.position.y ? shift.value : 0); const y = node.position.y + pushed(node.position.y) + opened(node.position.y); - if (original === open) return { ...node, position: { x: x - (OPEN_WIDTH - NODE_WIDTH) / 2, y }, zIndex: 10 }; + if (original === open) return { ...node, position: { x, y }, zIndex: 10 }; // A lane grows with the cards inside it. if (node.type === "lane" && node.style) { const top = node.position.y; const bottom = top + parseFloat(node.style.height); const height = bottom + pushed(bottom) + opened(bottom) - y; - return { ...node, position: { x, y }, style: { ...node.style, height: `${height}px` } }; + const width = parseFloat(String(node.style.width)) + (holdsOpen(node) ? WIDEN : 0); + return { ...node, position: { x, y }, style: { ...node.style, width: `${width}px`, height: `${height}px` } }; } return { ...node, position: { x, y } }; });