Skip to content

Commit

Permalink
Scroll collapsed file into view (go-gitea#23702)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpraet authored and Linux User committed Apr 4, 2023
1 parent 8d88f14 commit 92b167b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
7 changes: 7 additions & 0 deletions web_src/css/repository.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
4 changes: 2 additions & 2 deletions web_src/css/review.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
3 changes: 3 additions & 0 deletions web_src/js/features/file-fold.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 92b167b

Please sign in to comment.