From 0f5c19664e87b527e4e02d4df82e5f2dfe7742be Mon Sep 17 00:00:00 2001 From: Brenley Dueck Date: Mon, 26 Oct 2026 17:03:55 -0500 Subject: [PATCH] fix: reload the scratchpad after importing files from the URL hash --- packages/playground/src/pages/edit.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/playground/src/pages/edit.tsx b/packages/playground/src/pages/edit.tsx index c1a73c2a..e22d9642 100644 --- a/packages/playground/src/pages/edit.tsx +++ b/packages/playground/src/pages/edit.tsx @@ -92,6 +92,8 @@ export const Edit = () => { }, }; + // The scratchpad resource reads localStorage before this effect runs, so a hash import must refetch it. + const [scratchpadVersion, setScratchpadVersion] = createSignal(0); createEffect(() => { if (!scratchpad()) return; if (location.query.hash) { @@ -104,6 +106,7 @@ export const Edit = () => { files: initialTabs.map((x) => ({ name: x.name, content: x.source })), }), ); + setScratchpadVersion((v) => v + 1); navigate('/', { replace: true }); } }); @@ -189,8 +192,11 @@ export const Edit = () => { context.setSolidVersion(undefined); }); - const [resource, { mutate }] = createResource( - () => ({ repl: params.repl, scratchpad: !!scratchpad() }), + const [resource, { mutate }] = createResource< + APIRepl, + { repl: string | undefined; scratchpad: boolean; scratchpadVersion: number } + >( + () => ({ repl: params.repl, scratchpad: !!scratchpad(), scratchpadVersion: scratchpadVersion() }), async ({ repl, scratchpad }): Promise => { if (disableFetch) { disableFetch = undefined;