From 11c7fdcb8bf214d510c3206d45c8165cbde9ad07 Mon Sep 17 00:00:00 2001 From: stroblme Date: Mon, 5 Oct 2026 18:19:38 +0200 Subject: [PATCH] Centre a node arrived on from another screen The viewport effect marked the selection as centred before the layout had placed anything, so an arrival at ?node= fitted the whole flow. It is recorded once the fit has run. --- frontend/src/components/Flow/FlowEditor.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/Flow/FlowEditor.tsx b/frontend/src/components/Flow/FlowEditor.tsx index ec77e56..cc22051 100644 --- a/frontend/src/components/Flow/FlowEditor.tsx +++ b/frontend/src/components/Flow/FlowEditor.tsx @@ -677,9 +677,11 @@ function FlowEditorInner({ const centred = useRef(null) // biome-ignore lint/correctness/useExhaustiveDependencies: refit when the shape or the panel changes, not on every render. useEffect(() => { + // Recorded as centred only once the fit below has run: arriving from + // another screen selects before the layout has answered, and spending the + // selection on the early returns is what fitted the whole flow instead. const focus = selectedId && selectedId !== centred.current ? selectedId : null - centred.current = selectedId // A phone's sheet covers the canvas outright, and so does the expanded // editor: there is no viewport to aim. if (editorExpanded) return @@ -695,6 +697,7 @@ function FlowEditorInner({ : { ...view, duration }, ) fitted.current = true + centred.current = selectedId }) return () => cancelAnimationFrame(frame) }, [