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. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013GAeg4Jo6xjZzjwy9QDWMQ
This commit is contained in:
@@ -677,9 +677,11 @@ function FlowEditorInner({
|
|||||||
const centred = useRef<string | null>(null)
|
const centred = useRef<string | null>(null)
|
||||||
// biome-ignore lint/correctness/useExhaustiveDependencies: refit when the shape or the panel changes, not on every render.
|
// biome-ignore lint/correctness/useExhaustiveDependencies: refit when the shape or the panel changes, not on every render.
|
||||||
useEffect(() => {
|
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 =
|
const focus =
|
||||||
selectedId && selectedId !== centred.current ? selectedId : null
|
selectedId && selectedId !== centred.current ? selectedId : null
|
||||||
centred.current = selectedId
|
|
||||||
// A phone's sheet covers the canvas outright, and so does the expanded
|
// A phone's sheet covers the canvas outright, and so does the expanded
|
||||||
// editor: there is no viewport to aim.
|
// editor: there is no viewport to aim.
|
||||||
if (editorExpanded) return
|
if (editorExpanded) return
|
||||||
@@ -695,6 +697,7 @@ function FlowEditorInner({
|
|||||||
: { ...view, duration },
|
: { ...view, duration },
|
||||||
)
|
)
|
||||||
fitted.current = true
|
fitted.current = true
|
||||||
|
centred.current = selectedId
|
||||||
})
|
})
|
||||||
return () => cancelAnimationFrame(frame)
|
return () => cancelAnimationFrame(frame)
|
||||||
}, [
|
}, [
|
||||||
|
|||||||
Reference in New Issue
Block a user