Browse Source

Scroll collapsed file into view (#23702)

tags/v1.20.0-rc0
Jimmy Praet 1 year ago
parent
commit
54197b67f9
No account linked to committer's email address
3 changed files with 12 additions and 2 deletions
  1. 7
    0
      web_src/css/repository.css
  2. 2
    2
      web_src/css/review.css
  3. 3
    0
      web_src/js/features/file-fold.js

+ 7
- 0
web_src/css/repository.css View File

@@ -1867,6 +1867,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 */

+ 2
- 2
web_src/css/review.css View File

@@ -246,12 +246,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;
}
}

+ 3
- 0
web_src/js/features/file-fold.js View File

@@ -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.

Loading…
Cancel
Save