From 7e8f65317eb3206f5a23c711c78655be2d65e0d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Boduro=C4=9Flu?= <80620802+burakboduroglu@users.noreply.github.com> Date: Wed, 22 Jul 2026 12:49:47 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20=E2=9C=8F=EF=B8=8F=20prevent=20DrawCanva?= =?UTF-8?q?s=20from=20resetting=20strokes=20when=20drawing=20or=20updating?= =?UTF-8?q?=20props=20-=20guard=20initialScene=20effect=20in=20DrawCanvas?= =?UTF-8?q?=20with=20lastLoadedScene=20check=20to=20prevent=20resetting=20?= =?UTF-8?q?strokes=20mid-session=20-=20set=20default=20background=20ruling?= =?UTF-8?q?=20to=20grid=20for=20new=20drawing=20canvases=20-=20verify=20pr?= =?UTF-8?q?oduction=20build=20passes=20and=20202/202=20vitest=20unit=20tes?= =?UTF-8?q?ts=20pass?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ui/draw-canvas.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/ui/draw-canvas.tsx b/src/components/ui/draw-canvas.tsx index fc600bd..a0a331f 100644 --- a/src/components/ui/draw-canvas.tsx +++ b/src/components/ui/draw-canvas.tsx @@ -125,12 +125,16 @@ export function DrawCanvas(props: { // shrinking a big drawing to fit we keep it 1:1 and pan its content into the // corner (you move around it from there). untrack keeps redraw's read of // strokes() from turning this into a self-triggering loop. + let lastLoadedScene: DrawScene | null | undefined = Symbol("uninitialized") as any; + createEffect(() => { const scene = props.initialScene; + if (scene === lastLoadedScene) return; + lastLoadedScene = scene; untrack(() => { const next = scene ? scene.strokes : []; setStrokes(next); - setBg(scene?.bg ?? "none"); // old drawings lack bg → plain, preserving their original look + setBg(scene?.bg ?? "grid"); // default grid background for new/edited drawings setZoom(1); // a reopened drawing starts at 100% const b = strokesBounds(next); setPan(b ? { x: EXPORT_MARGIN - b.x, y: EXPORT_MARGIN - b.y } : { x: 0, y: 0 });