fix: Preview on an earlier block opens that block's artifact when the pane was closed (#32688)

This commit is contained in:
G30 authored and GitHub committed 2026-10-21 02:16:11 +09:00
1 parent a944564c20
commit 9862a5bd61
1 file changed
+8 -7
+8 -7
View File
@@ -92,13 +92,6 @@
};
onMount(() => {
const unsubscribeArtifactCode = artifactCode.subscribe((value) => {
if (contents) {
const codeIdx = contents.findIndex((content) => content.content.includes(value));
selectedContentIdx = codeIdx !== -1 ? codeIdx : 0;
}
});
const unsubscribeArtifactContents = artifactContents.subscribe((value) => {
const newContents = value ?? [];
console.log('Artifact contents updated:', newContents);
@@ -116,9 +109,17 @@
contents = newContents;
});
const unsubscribeArtifactCode = artifactCode.subscribe((value) => {
if (contents && value) {
const codeIdx = contents.findIndex((content) => content.content.includes(value));
selectedContentIdx = codeIdx !== -1 ? codeIdx : 0;
}
});
return () => {
unsubscribeArtifactCode();
unsubscribeArtifactContents();
artifactCode.set(null);
};
});
</script>