From 34c597b3b3f525cd5ce2d64f41468f38f5b7ef69 Mon Sep 17 00:00:00 2001 From: Matias Chomicki Date: Wed, 8 Jan 2025 17:40:41 +0000 Subject: [PATCH] Logs Panel: fix preview and scroll position interaction (#98687) --- public/app/plugins/panel/logs/LogsPanel.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/public/app/plugins/panel/logs/LogsPanel.tsx b/public/app/plugins/panel/logs/LogsPanel.tsx index 3f007c838f6..5b92496f86c 100644 --- a/public/app/plugins/panel/logs/LogsPanel.tsx +++ b/public/app/plugins/panel/logs/LogsPanel.tsx @@ -283,8 +283,8 @@ export const LogsPanel = ({ * In dashboards, users with newest logs at the bottom have the expectation of keeping the scroll at the bottom * when new data is received. See https://github.com/grafana/grafana/pull/37634 */ - if (isAscending && data.request?.app === CoreApp.Dashboard) { - scrollElement.scrollTo(0, logsContainerRef.current.offsetHeight); + if (data.request?.app === CoreApp.Dashboard || data.request?.app === CoreApp.PanelEditor) { + scrollElement.scrollTo(0, isAscending ? logsContainerRef.current.scrollHeight : 0); } }, [data.request?.app, isAscending, scrollElement, logRows]); @@ -469,7 +469,8 @@ export const LogsPanel = ({ onClickHideField={displayedFields !== undefined ? onClickHideField : undefined} logRowMenuIconsBefore={isReactNodeArray(logRowMenuIconsBefore) ? logRowMenuIconsBefore : undefined} logRowMenuIconsAfter={isReactNodeArray(logRowMenuIconsAfter) ? logRowMenuIconsAfter : undefined} - renderPreview + // Ascending order causes scroll to stick to the bottom, so previewing is futile + renderPreview={isAscending ? false : true} /> {showCommonLabels && isAscending && renderCommonLabels()}