From 0775387918cc2520e173cddf10c0886b0a18acba Mon Sep 17 00:00:00 2001 From: Matias Chomicki Date: Fri, 12 Dec 2025 13:37:49 +0100 Subject: [PATCH] LogListSearch: don't autoscroll with matching-logs enabled --- .../features/logs/components/panel/LogListSearch.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/public/app/features/logs/components/panel/LogListSearch.tsx b/public/app/features/logs/components/panel/LogListSearch.tsx index 3cdd1cbbe3d..03fbbda44f7 100644 --- a/public/app/features/logs/components/panel/LogListSearch.tsx +++ b/public/app/features/logs/components/panel/LogListSearch.tsx @@ -61,8 +61,13 @@ export const LogListSearch = ({ listRef, logs }: Props) => { } const prev = currentResult > 0 ? currentResult - 1 : matches.length - 1; setCurrentResult(prev); - listRef?.scrollToItem(logs.indexOf(matches[prev]), 'center'); - }, [currentResult, listRef, logs, matches]); + if (!filterLogs) { + // Filtering logs will only display logs containing the current search. + // Not only scrolling is not needed in this circumstance, but it also can + // trigger, incorrectly, infinite scrolling. + listRef?.scrollToItem(logs.indexOf(matches[prev]), 'center'); + } + }, [currentResult, filterLogs, listRef, logs, matches]); const nextResult = useCallback(() => { if (currentResult === null) { @@ -78,7 +83,7 @@ export const LogListSearch = ({ listRef, logs }: Props) => { setCurrentResult(null); return; } - if (!currentResult) { + if (currentResult === null) { setCurrentResult(0); listRef?.scrollToItem(logs.indexOf(matches[0]), 'center'); }