From: Jeremy Davis Date: Wed, 4 Mar 2020 16:20:20 +0000 (+0100) Subject: SONAR-12752 Improve horizontal scrolling of snippets X-Git-Tag: 8.3.0.34182~170 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=00aff7ff9a3fdb71ff5e0015e839958a7e0b2a89;p=sonarqube.git SONAR-12752 Improve horizontal scrolling of snippets --- 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 }); }