Skip to content

Commit 92b167b

Browse files
jpraetLinux User
authored and
Linux User
committed
Scroll collapsed file into view (go-gitea#23702)
1 parent 8d88f14 commit 92b167b

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

web_src/css/repository.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1862,6 +1862,13 @@
18621862
.diff-file-box {
18631863
border: 1px solid transparent;
18641864
border-radius: var(--border-radius);
1865+
scroll-margin-top: 47px; /* match .repository .diff-detail-box */
1866+
}
1867+
1868+
@media (max-width: 991px) {
1869+
.diff-file-box {
1870+
scroll-margin-top: 77px; /* match .repository .diff-detail-box */
1871+
}
18651872
}
18661873

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

web_src/css/review.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,12 @@ a.blob-excerpt:hover {
242242
display: none;
243243
}
244244

245-
.pull.files.diff [id] {
245+
.pull.files.diff .comment {
246246
scroll-margin-top: 99px;
247247
}
248248

249249
@media (max-width: 991px) {
250-
.pull.files.diff [id] {
250+
.pull.files.diff .comment {
251251
scroll-margin-top: 130px;
252252
}
253253
}

web_src/js/features/file-fold.js

Lines changed: 3 additions & 0 deletions
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)