From 03d76863cb9332e61e3811c812eb4ce7da8bb5f5 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 5 Apr 2026 21:18:43 +0200 Subject: [PATCH] fix: clicking annotation enters transcribe mode and scrolls to block When clicking a turquoise annotation on the PDF: - If not in transcribe mode, enters it and loads blocks - Waits for DOM render, then scrolls to the corresponding block card Co-Authored-By: Claude Sonnet 4.6 --- frontend/src/routes/documents/[id]/+page.svelte | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/frontend/src/routes/documents/[id]/+page.svelte b/frontend/src/routes/documents/[id]/+page.svelte index b692dada..88082ceb 100644 --- a/frontend/src/routes/documents/[id]/+page.svelte +++ b/frontend/src/routes/documents/[id]/+page.svelte @@ -124,16 +124,22 @@ function handleBlockFocus(blockId: string) { } } -function handleAnnotationClick(annotationId: string) { +async function handleAnnotationClick(annotationId: string) { activeAnnotationId = annotationId; - // In transcribe mode, focus the block that owns this annotation - if (transcribeMode) { + + if (!transcribeMode) { + transcribeMode = true; + await loadTranscriptionBlocks(); + } + + // Wait for DOM to render the blocks, then scroll to the matching one + requestAnimationFrame(() => { const block = transcriptionBlocks.find((b) => b.annotationId === annotationId); if (block) { const el = document.querySelector(`[data-block-id="${block.id}"]`); el?.scrollIntoView({ behavior: 'smooth', block: 'nearest' }); } - } + }); } // Load blocks when transcribe mode is entered