@@ -5,22 +5,16 @@ import {svg} from '../svg.js';
5
5
// The fold arrow is the icon displayed on the upper left of the file box, especially intended for components having the 'fold-file' class.
6
6
// The file content box is the box that should be hidden or shown, especially intended for components having the 'file-content' class.
7
7
//
8
- export function setFileFolding ( fileContentBox , foldArrow , newFold , isFromViewed = false ) {
8
+ export function setFileFolding ( fileContentBox , foldArrow , newFold ) {
9
9
const diffFileHeader = fileContentBox . querySelector ( '.diff-file-header' ) ;
10
10
foldArrow . innerHTML = svg ( `octicon-chevron-${ newFold ? 'right' : 'down' } ` , 18 ) ;
11
11
fileContentBox . setAttribute ( 'data-folded' , newFold ) ;
12
12
// scroll position needs to be adjusted only when folding the file
13
13
// and scrollY is greater than current file header's offsetTop
14
14
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
22
16
window . scrollTo ( {
23
- top : scrollTargetoffsetTop - document . querySelector ( '.diff-detail-box' ) . offsetHeight ,
17
+ top : fileContentBox . offsetTop - document . querySelector ( '.diff-detail-box' ) . offsetHeight ,
24
18
behavior : 'instant'
25
19
} ) ;
26
20
}
0 commit comments