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

This commit is contained in:
G30 2026-10-20 13:16:11 -04:00 • committed by GitHub
parent a944564c20
commit 9862a5bd61
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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>