From 26865a0a572fc3b26085d6e4acf00c23492a1ffa Mon Sep 17 00:00:00 2001 From: Judicael <46365844+judicaelandria@users.noreply.github.com> Date: Thu, 18 Aug 2022 15:48:05 +0300 Subject: [PATCH] refix the load document from URL --- packages/tldraw/src/Tldraw.tsx | 4 +++- packages/tldraw/src/state/TldrawApp.ts | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/tldraw/src/Tldraw.tsx b/packages/tldraw/src/Tldraw.tsx index e3908b0ac..0453f4c7f 100644 --- a/packages/tldraw/src/Tldraw.tsx +++ b/packages/tldraw/src/Tldraw.tsx @@ -364,6 +364,8 @@ const InnerTldraw = React.memo(function InnerTldraw({ }: InnerTldrawProps) { const app = useTldrawApp() const [dialogContainer, setDialogContainer] = React.useState(null) + + // In dev, we need to delete the prefixed const entry = process.env.NODE_ENV === 'development' ? window.location.hash.replace('#/develop/', '') @@ -384,7 +386,7 @@ const InnerTldraw = React.memo(function InnerTldraw({ } } } - }, [decodedPage]) + }, [decodedPage, app]) const rWrapper = React.useRef(null) diff --git a/packages/tldraw/src/state/TldrawApp.ts b/packages/tldraw/src/state/TldrawApp.ts index 08c9cbae7..d40220694 100644 --- a/packages/tldraw/src/state/TldrawApp.ts +++ b/packages/tldraw/src/state/TldrawApp.ts @@ -1400,10 +1400,11 @@ export class TldrawApp extends StateManager { document?: TDDocument, page?: TDPage, pageState?: Record - ): this => { + ) => { if (document) { this.loadDocument(document) - return this + this.zoomToFit() + this.persist({}) } else { this.setIsLoading(true) const { currentPageId } = this @@ -1437,7 +1438,9 @@ export class TldrawApp extends StateManager { }, } this.setIsLoading(false) - return this.setState(state) + this.setState(state) + this.zoomToFit() + this.persist({}) } }