Improve scroll-to-result functionality with smoother scrolling and fallback adjustments

This commit is contained in:
2026-01-28 20:14:52 +00:00
parent 36804c1c24
commit 6ccca7ae5e

View File

@@ -643,11 +643,11 @@ function scrollToResult() {
if (lineIndex === undefined) return; if (lineIndex === undefined) return;
const lineNumber = lineIndex + 1; // Convert to 1-based line number const lineNumber = lineIndex + 1; // Convert to 1-based line number
// Retry logic for virtual scroller rendering // Retry logic for virtual scroller rendering
const attemptScroll = (attempt = 0) => { const attemptScroll = (attempt = 0) => {
const lineElement = document.querySelector(`[data-line="${lineNumber}"]`); const lineElement = document.querySelector(`[data-line="${lineNumber}"]`);
if (lineElement) { if (lineElement) {
// Element is rendered, scroll it into view // Element is rendered, scroll it into view
lineElement.scrollIntoView({ behavior: 'smooth', block: 'center' }); lineElement.scrollIntoView({ behavior: 'smooth', block: 'center' });
@@ -660,13 +660,15 @@ function scrollToResult() {
// Fallback: scroll container to approximate position // Fallback: scroll container to approximate position
const container = document.querySelector('.scroller, .lines-container'); const container = document.querySelector('.scroller, .lines-container');
if (container) { if (container) {
const estimatedScroll = (lineIndex / displayLines.value.length) * (container.scrollHeight - container.clientHeight); const estimatedScroll =
(lineIndex / displayLines.value.length) *
(container.scrollHeight - container.clientHeight);
container.scrollTop = estimatedScroll; container.scrollTop = estimatedScroll;
} }
return false; return false;
} }
}; };
attemptScroll(); attemptScroll();
} }