Skip to content

Commit 654c88d

Browse files
committed
Fix stale cells when switching examples (key Notebook on slug)
1 parent 0be44df commit 654c88d

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

src/routes/[package]/[version]/examples/[slug]/+page.svelte

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,16 @@
4343
$effect(() => {
4444
const slug = data.meta.slug;
4545
46-
// Reset namespace and notebook state when switching examples
46+
// Reset namespace when switching examples
47+
// Note: {#key} on Notebook handles component destruction and store cleanup
4748
return async () => {
4849
try {
4950
const { reset } = await import('$lib/pyodide');
5051
await reset();
5152
} catch {
5253
// Ignore if Pyodide not loaded
5354
}
54-
notebookStore.resetAllCells();
55+
notebookStore.reset();
5556
};
5657
});
5758
@@ -88,14 +89,16 @@
8889
downloadUrl={`${versionBasePath}/notebooks/${data.meta.file}`}
8990
/>
9091

91-
<Notebook
92-
notebook={data.notebook}
93-
basePath={versionBasePath}
94-
precomputedOutputs={data.outputs}
95-
{figuresBasePath}
96-
showStaticOutputs={true}
97-
executable={data.meta.executable}
98-
/>
92+
{#key data.meta.slug}
93+
<Notebook
94+
notebook={data.notebook}
95+
basePath={versionBasePath}
96+
precomputedOutputs={data.outputs}
97+
{figuresBasePath}
98+
showStaticOutputs={true}
99+
executable={data.meta.executable}
100+
/>
101+
{/key}
99102
</div>
100103

101104
<style>

0 commit comments

Comments
 (0)