Skip to content

Commit bc5c8ea

Browse files
committed
make both cases to have same behavior
1 parent 579bd34 commit bc5c8ea

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

Diff for: web_src/js/features/file-fold.js

+3-9
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,16 @@ import {svg} from '../svg.js';
55
// The fold arrow is the icon displayed on the upper left of the file box, especially intended for components having the 'fold-file' class.
66
// The file content box is the box that should be hidden or shown, especially intended for components having the 'file-content' class.
77
//
8-
export function setFileFolding(fileContentBox, foldArrow, newFold, isFromViewed = false) {
8+
export function setFileFolding(fileContentBox, foldArrow, newFold) {
99
const diffFileHeader = fileContentBox.querySelector('.diff-file-header');
1010
foldArrow.innerHTML = svg(`octicon-chevron-${newFold ? 'right' : 'down'}`, 18);
1111
fileContentBox.setAttribute('data-folded', newFold);
1212
// scroll position needs to be adjusted only when folding the file
1313
// and scrollY is greater than current file header's offsetTop
1414
if (newFold && window.scrollY > diffFileHeader.offsetTop) {
15-
// if the file is folded by clicking the "fold file" icon, scroll to current file header
16-
let scrollTargetoffsetTop = fileContentBox.offsetTop;
17-
if (isFromViewed) {
18-
// if the file is folded by clicking viewed, scroll to next file header
19-
const nextDiffBox = fileContentBox.nextElementSibling;
20-
scrollTargetoffsetTop = nextDiffBox.offsetTop;
21-
}
15+
// Scroll to current file header
2216
window.scrollTo({
23-
top: scrollTargetoffsetTop - document.querySelector('.diff-detail-box').offsetHeight,
17+
top: fileContentBox.offsetTop - document.querySelector('.diff-detail-box').offsetHeight,
2418
behavior: 'instant'
2519
});
2620
}

Diff for: web_src/js/features/pull-view-file.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export function initViewedCheckboxListenerFor() {
6565

6666
// Fold the file accordingly
6767
const parentBox = form.closest('.diff-file-header');
68-
setFileFolding(parentBox.closest('.file-content'), parentBox.querySelector('.fold-file'), this.checked, true);
68+
setFileFolding(parentBox.closest('.file-content'), parentBox.querySelector('.fold-file'), this.checked);
6969
});
7070
}
7171
}

0 commit comments

Comments
 (0)