Skip to content

fix: reload the scratchpad after importing files from the URL hash - #202

Closed
brenelz wants to merge 1 commit into
solidjs:mainfrom
brenelz:fix/hash-import-reload
Closed

brenelz wants to merge 1 commit into
solidjs:mainfrom
brenelz:fix/hash-import-reload

Conversation

@brenelz

@brenelz brenelz commented Oct 26, 2026

Copy link
Copy Markdown

Opening the scratchpad with files in the URL hash (/#<compressed tabs>) shows the default counter instead of the imported files.

The scratchpad resource reads localStorage when the edit page is created, before the effect that handles the hash runs. The effect writes the imported files to localStorage and strips the hash, but nothing tells the resource to read again. The editor keeps the default tabs, and the autosave then writes them back over the import.

The effect now bumps a scratchpadVersion signal after writing the import, and the resource source includes it, so the resource reads the scratchpad again and the editor shows the imported files. #201 handles this the same way in its Solid 2 port. This change fixes it on the current app so hash links and iframe embeds work before that lands. The motivating case is embedding playground examples in the Solid docs (solidjs/solid-docs#1669).

Verified with a production build (pnpm build, then vite preview) in Chromium, using a hash that holds a main.tsx plus an import_map.json pinning solid-js@2.0.0-rc.18:

  • With empty storage, the hash URL shows the imported code in the editor and preview, and the scratchpad saves it. On playground.solidjs.com today it shows the default counter.
  • With an existing scratchpad, the hash URL replaces it. Today the editor keeps the old code.
  • Reloading / after an import keeps the imported code.
  • Visiting / with no hash and empty storage still shows the default counter.

oxfmt --check, oxlint and tsc --noEmit in packages/playground pass.

🤖 Generated with Claude Code

@brenelz brenelz closed this Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant