From 54197b67f988bd8e425c542934dfa2517d1152f3 Mon Sep 17 00:00:00 2001 From: Jimmy Praet Date: Wed, 5 Apr 2023 01:51:42 +0200 Subject: Scroll collapsed file into view (#23702) --- web_src/js/features/file-fold.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'web_src/js') diff --git a/web_src/js/features/file-fold.js b/web_src/js/features/file-fold.js index 0d5be7cf60..8321b9b19e 100644 --- a/web_src/js/features/file-fold.js +++ b/web_src/js/features/file-fold.js @@ -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. -- cgit v1.2.3