From bbdb26511aa04dfb1ef90f5285bde7a30a57afb8 Mon Sep 17 00:00:00 2001 From: blessedcoolant <54517381+blessedcoolant@users.noreply.github.com> Date: Tue, 11 Jul 2023 09:44:36 +1200 Subject: [PATCH] feat: Fit to view on load rather than using older position --- .../src/features/nodes/components/ui/LoadNodesButton.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/invokeai/frontend/web/src/features/nodes/components/ui/LoadNodesButton.tsx b/invokeai/frontend/web/src/features/nodes/components/ui/LoadNodesButton.tsx index e32003b2b2..d71da68fa9 100644 --- a/invokeai/frontend/web/src/features/nodes/components/ui/LoadNodesButton.tsx +++ b/invokeai/frontend/web/src/features/nodes/components/ui/LoadNodesButton.tsx @@ -12,7 +12,7 @@ import { useReactFlow } from 'reactflow'; const LoadNodesButton = () => { const { t } = useTranslation(); const dispatch = useAppDispatch(); - const { setViewport } = useReactFlow(); + const { fitView } = useReactFlow(); const uploadedFileRef = useRef<() => void>(null); @@ -36,10 +36,10 @@ const LoadNodesButton = () => { } if (retrievedNodeTree) { - const { x = 0, y = 0, zoom = 1 } = retrievedNodeTree.viewport; dispatch(loadFileNodes(retrievedNodeTree.nodes)); dispatch(loadFileEdges(retrievedNodeTree.edges)); - setViewport({ x, y, zoom }); + fitView(); + dispatch( addToast( makeToast({ title: t('toast.nodesLoaded'), status: 'success' }) @@ -56,7 +56,7 @@ const LoadNodesButton = () => { // Cleanup uploadedFileRef.current?.(); }, - [setViewport, dispatch, t] + [fitView, dispatch, t] ); return (