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.
This commit is contained in:
2026-10-05 18:19:38 +02:00
parent a677409079
commit 11c7fdcb8b
+4 -1
View File
@@ -677,9 +677,11 @@ function FlowEditorInner({
const centred = useRef<string | null>(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)
}, [