From 6980cb8657277a25b2772af8f6d487f82e545864 Mon Sep 17 00:00:00 2001 From: FragginWagon Date: Wed, 28 Jan 2026 20:12:34 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Enhance=20scrollToResult=20function?= =?UTF-8?q?=20with=20fallback=20and=20retry=20logic=20for=20better=20handl?= =?UTF-8?q?ing=20of=20virtual=20scroller=20scenarios?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/GamemasterExplorer.vue | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/code/websites/pokedex.online/src/views/GamemasterExplorer.vue b/code/websites/pokedex.online/src/views/GamemasterExplorer.vue index dc18f2b..b8cf825 100644 --- a/code/websites/pokedex.online/src/views/GamemasterExplorer.vue +++ b/code/websites/pokedex.online/src/views/GamemasterExplorer.vue @@ -615,8 +615,30 @@ function goToPrevResult() { function scrollToResult() { const lineIndex = searchResults.value[currentResultIndex.value]; - const lineElement = document.querySelector(`[data-line="${lineIndex + 1}"]`); - lineElement?.scrollIntoView({ behavior: 'smooth', block: 'center' }); + if (lineIndex === undefined) return; + + const lineNumber = lineIndex + 1; // Convert to 1-based line number + const lineElement = document.querySelector(`[data-line="${lineNumber}"]`); + + if (lineElement) { + // Scroll to element + lineElement.scrollIntoView({ behavior: 'smooth', block: 'center' }); + + // For virtual scroller, ensure it's rendered by waiting a tick + if (!lineElement.textContent) { + setTimeout(() => { + const retryElement = document.querySelector(`[data-line="${lineNumber}"]`); + retryElement?.scrollIntoView({ behavior: 'smooth', block: 'center' }); + }, 100); + } + } else { + // Fallback: scroll container to approximate position + const container = document.querySelector('.scroller, .lines-container'); + if (container) { + const estimatedScroll = (lineIndex / displayLines.value.length) * (container.scrollHeight - container.clientHeight); + container.scrollTop = estimatedScroll; + } + } } function applyHistoryItem(item) {