From 2de3dc30bf874b9e4797c4a1574bda6fde49eabb Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Wed, 29 Oct 2025 10:42:44 +0100 Subject: [PATCH] frontend --- frontend/src/index.jsx | 42 +++++++++++++++++++++++++++++++++++++++++ frontend/src/styles.css | 2 +- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/frontend/src/index.jsx b/frontend/src/index.jsx index f5988d4..88f1c15 100644 --- a/frontend/src/index.jsx +++ b/frontend/src/index.jsx @@ -4842,6 +4842,48 @@ const AppLayout = () => { return ordered; }, [selectionOrder, documentLookup, selectedDocumentIds]); + const lastScrolledDetailDocRef = useRef(null); + + useEffect(() => { + if (!orderedSelectedDocuments.length) { + lastScrolledDetailDocRef.current = null; + return; + } + + let lastSelectedId = null; + for (let index = selectionOrder.length - 1; index >= 0; index -= 1) { + const key = selectionOrder[index]; + if (isDocumentRowKey(key)) { + lastSelectedId = getRowId(key); + if (lastSelectedId) { + break; + } + } + } + + if (!lastSelectedId && orderedSelectedDocuments.length) { + const fallbackDoc = orderedSelectedDocuments[orderedSelectedDocuments.length - 1]; + lastSelectedId = fallbackDoc?.id || null; + } + + if (!lastSelectedId || lastScrolledDetailDocRef.current === lastSelectedId) { + return; + } + + const targetElement = + document.getElementById(`document-row-${lastSelectedId}`) || + document.getElementById(`document-card-${lastSelectedId}`); + + if (!targetElement) { + return; + } + + lastScrolledDetailDocRef.current = lastSelectedId; + requestAnimationFrame(() => { + targetElement.scrollIntoView({ block: 'nearest', behavior: 'smooth' }); + }); + }, [orderedSelectedDocuments, selectionOrder, documentsViewMode]); + const { breadcrumbs, missingBreadcrumbAncestors } = useMemo(() => { const chain = []; const seen = new Set(); diff --git a/frontend/src/styles.css b/frontend/src/styles.css index 26faa22..8a5d318 100644 --- a/frontend/src/styles.css +++ b/frontend/src/styles.css @@ -1805,7 +1805,7 @@ button.danger:hover:not([disabled]) { } .document-card.selected .document-thumbnail-wrapper { - background-color: var(--accent-soft); + background-color: var(--selection-soft); } .document-card:hover .document-thumbnail-wrapper,