From 00aff7ff9a3fdb71ff5e0015e839958a7e0b2a89 Mon Sep 17 00:00:00 2001 From: Jeremy Davis Date: Wed, 4 Mar 2020 17:20:20 +0100 Subject: [PATCH] SONAR-12752 Improve horizontal scrolling of snippets --- .../issues/crossComponentSourceViewer/SnippetViewer.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/SnippetViewer.tsx b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/SnippetViewer.tsx index a40025118cd..7fc1ef11460 100644 --- a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/SnippetViewer.tsx +++ b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/SnippetViewer.tsx @@ -65,8 +65,6 @@ interface Props { snippet: T.SourceLine[]; } -const SCROLL_LEFT_OFFSET = 32; - export default class SnippetViewer extends React.PureComponent { snippetNodeRef: React.RefObject; @@ -82,9 +80,11 @@ export default class SnippetViewer extends React.PureComponent { const parent = this.snippetNodeRef.current as Element; if (parent) { + const offset = parent.getBoundingClientRect().width / 2; + scrollHorizontally(element, { - leftOffset: SCROLL_LEFT_OFFSET, - rightOffset: parent.getBoundingClientRect().width - SCROLL_LEFT_OFFSET, + leftOffset: offset, + rightOffset: offset, parent }); } -- 2.39.5