Skip to content

Commit 348839e

Browse files
committed
Scroll collapsed file into view
1 parent e37ef4d commit 348839e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

web_src/js/features/file-fold.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ import {svg} from '../svg.js';
77
//
88
export function setFileFolding(fileContentBox, foldArrow, newFold) {
99
foldArrow.innerHTML = svg(`octicon-chevron-${newFold ? 'right' : 'down'}`, 18);
10-
fileContentBox.setAttribute('data-folded', newFold);
10+
fileContentBox.setAttribute('data-folded', newFold);
11+
if (newFold && fileContentBox.getBoundingClientRect().top < 0) {
12+
fileContentBox.scrollIntoView();
13+
}
1114
}
1215

1316
// Like `setFileFolding`, except that it automatically inverts the current file folding state.

0 commit comments

Comments
 (0)