From 9f1efe4747706415b63faac5070c4fd3afbc522a Mon Sep 17 00:00:00 2001 From: Jimmy Praet Date: Sun, 27 Jun 2021 16:36:49 +0200 Subject: [PATCH] Add scroll-margin-top to account for sticky header (#16269) Fixes #16263 Co-authored-by: zeripath --- web_src/js/index.js | 2 +- web_src/less/_review.less | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/web_src/js/index.js b/web_src/js/index.js index c00b3aaeb076c..67548f5d9d82d 100644 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -1343,7 +1343,7 @@ function initPullRequestReview() { $(`#code-comments-${id}`).removeClass('hide'); $(`#code-preview-${id}`).removeClass('hide'); $(`#hide-outdated-${id}`).removeClass('hide'); - $(window).scrollTop(commentDiv.offset().top); + commentDiv[0].scrollIntoView(); } } } diff --git a/web_src/less/_review.less b/web_src/less/_review.less index 9197050913404..2b15eec82d7c7 100644 --- a/web_src/less/_review.less +++ b/web_src/less/_review.less @@ -173,3 +173,11 @@ a.blob-excerpt:hover { .review-box > .segment { border: none !important; } + +.pull.files.diff [id] { + scroll-margin-top: 99px; + + @media @mediaMdAndDown { + scroll-margin-top: 130px; + } +}