mirror of
https://codeberg.org/forgejo/forgejo
synced 2024-11-29 21:26:10 +01:00
Backport #23702 by @jpraet
Fixes #23701, #23515.
Alternate approach to #23604 using CSS scroll-margin-top, which is also
taken into account for direct links to files in a diff:
* On the PR diff, this currently shows the previous file first:
https://try.gitea.io/jpraet/test/pulls/13/files#diff-b94d08b409f9d05fb65b6cccaf7b3e4ecc7cc333
* On the commit diff, the first line of the linked file is currently
under the sticky header:
1a19e6b14e (diff-b94d08b409f9d05fb65b6cccaf7b3e4ecc7cc333)
Co-authored-by: Jimmy Praet <jimmy.praet@ksz-bcss.fgov.be>
This commit is contained in:
parent
8d88f148d7
commit
df74ee0376
|
@ -1862,6 +1862,13 @@
|
||||||
.diff-file-box {
|
.diff-file-box {
|
||||||
border: 1px solid transparent;
|
border: 1px solid transparent;
|
||||||
border-radius: var(--border-radius);
|
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 */
|
/* TODO: this can potentially be made "global" by removing the class prefix */
|
||||||
|
|
|
@ -242,12 +242,12 @@ a.blob-excerpt:hover {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pull.files.diff [id] {
|
.pull.files.diff .comment {
|
||||||
scroll-margin-top: 99px;
|
scroll-margin-top: 99px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 991px) {
|
@media (max-width: 991px) {
|
||||||
.pull.files.diff [id] {
|
.pull.files.diff .comment {
|
||||||
scroll-margin-top: 130px;
|
scroll-margin-top: 130px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,9 @@ import {svg} from '../svg.js';
|
||||||
export function setFileFolding(fileContentBox, foldArrow, newFold) {
|
export function setFileFolding(fileContentBox, foldArrow, newFold) {
|
||||||
foldArrow.innerHTML = svg(`octicon-chevron-${newFold ? 'right' : 'down'}`, 18);
|
foldArrow.innerHTML = svg(`octicon-chevron-${newFold ? 'right' : 'down'}`, 18);
|
||||||
fileContentBox.setAttribute('data-folded', newFold);
|
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.
|
// Like `setFileFolding`, except that it automatically inverts the current file folding state.
|
||||||
|
|
Loading…
Reference in a new issue