From fd03e56c858d92cfc73774ae71d6b4c9710542b9 Mon Sep 17 00:00:00 2001 From: Marcel Date: Tue, 24 Mar 2026 11:28:44 +0100 Subject: [PATCH] fix(comments): remount AnnotationCommentPanel when switching annotations Wrap the panel in {#key activeAnnotationId} so Svelte destroys and recreates it on every annotation change, triggering onMount and loading the correct comments. Co-Authored-By: Claude Sonnet 4.6 --- frontend/src/lib/components/PdfViewer.svelte | 28 +++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/frontend/src/lib/components/PdfViewer.svelte b/frontend/src/lib/components/PdfViewer.svelte index cd51b52a..1a9ff68a 100644 --- a/frontend/src/lib/components/PdfViewer.svelte +++ b/frontend/src/lib/components/PdfViewer.svelte @@ -452,18 +452,20 @@ function zoomOut() { {/if} - {#if activeAnnotationId} - (activeAnnotationId = null)} - onCountChange={(count) => { - if (activeAnnotationId) commentCounts.set(activeAnnotationId, count); - }} - /> - {/if} + {#key activeAnnotationId} + {#if activeAnnotationId} + (activeAnnotationId = null)} + onCountChange={(count) => { + if (activeAnnotationId) commentCounts.set(activeAnnotationId, count); + }} + /> + {/if} + {/key} {/if}