Skip to content

Commit 54197b6

Browse files
authored
Scroll collapsed file into view (#23702)
1 parent 0983b23 commit 54197b6

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

web_src/css/repository.css

+7
Original file line numberDiff line numberDiff line change
@@ -1867,6 +1867,13 @@
18671867
.diff-file-box {
18681868
border: 1px solid transparent;
18691869
border-radius: var(--border-radius);
1870+
scroll-margin-top: 47px; /* match .repository .diff-detail-box */
1871+
}
1872+
1873+
@media (max-width: 991px) {
1874+
.diff-file-box {
1875+
scroll-margin-top: 77px; /* match .repository .diff-detail-box */
1876+
}
18701877
}
18711878

18721879
/* TODO: this can potentially be made "global" by removing the class prefix */

web_src/css/review.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,12 @@ a.blob-excerpt:hover {
246246
display: none;
247247
}
248248

249-
.pull.files.diff [id] {
249+
.pull.files.diff .comment {
250250
scroll-margin-top: 99px;
251251
}
252252

253253
@media (max-width: 991px) {
254-
.pull.files.diff [id] {
254+
.pull.files.diff .comment {
255255
scroll-margin-top: 130px;
256256
}
257257
}

web_src/js/features/file-fold.js

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import {svg} from '../svg.js';
88
export function setFileFolding(fileContentBox, foldArrow, newFold) {
99
foldArrow.innerHTML = svg(`octicon-chevron-${newFold ? 'right' : 'down'}`, 18);
1010
fileContentBox.setAttribute('data-folded', newFold);
11+
if (newFold && fileContentBox.getBoundingClientRect().top < 0) {
12+
fileContentBox.scrollIntoView();
13+
}
1114
}
1215

1316
// Like `setFileFolding`, except that it automatically inverts the current file folding state.

0 commit comments

Comments
 (0)