diff --git a/web_src/css/repository.css b/web_src/css/repository.css index 4bb49dc439..d67442b00a 100644 --- a/web_src/css/repository.css +++ b/web_src/css/repository.css @@ -1862,6 +1862,13 @@ .diff-file-box { border: 1px solid transparent; border-radius: var(--border-radius); + scroll-margin-top: 47px; /* match .repository .diff-detail-box */ +} + +@media (max-width: 991px) { + .diff-file-box { + scroll-margin-top: 77px; /* match .repository .diff-detail-box */ + } } /* TODO: this can potentially be made "global" by removing the class prefix */ diff --git a/web_src/css/review.css b/web_src/css/review.css index 7e628a9dfc..9e06ba133e 100644 --- a/web_src/css/review.css +++ b/web_src/css/review.css @@ -242,12 +242,12 @@ a.blob-excerpt:hover { display: none; } -.pull.files.diff [id] { +.pull.files.diff .comment { scroll-margin-top: 99px; } @media (max-width: 991px) { - .pull.files.diff [id] { + .pull.files.diff .comment { scroll-margin-top: 130px; } } diff --git a/web_src/js/features/file-fold.js b/web_src/js/features/file-fold.js index 0d5be7cf60..8321b9b19e 100644 --- a/web_src/js/features/file-fold.js +++ b/web_src/js/features/file-fold.js @@ -8,6 +8,9 @@ import {svg} from '../svg.js'; export function setFileFolding(fileContentBox, foldArrow, newFold) { foldArrow.innerHTML = svg(`octicon-chevron-${newFold ? 'right' : 'down'}`, 18); fileContentBox.setAttribute('data-folded', newFold); + if (newFold && fileContentBox.getBoundingClientRect().top < 0) { + fileContentBox.scrollIntoView(); + } } // Like `setFileFolding`, except that it automatically inverts the current file folding state.