From 348839ea85fafd62e24c61b84ce34813882a4820 Mon Sep 17 00:00:00 2001 From: Jimmy Praet Date: Sat, 25 Mar 2023 14:23:37 +0100 Subject: [PATCH 1/5] Scroll collapsed file into view --- web_src/js/features/file-fold.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/web_src/js/features/file-fold.js b/web_src/js/features/file-fold.js index 0d5be7cf60d2..4afbf1772399 100644 --- a/web_src/js/features/file-fold.js +++ b/web_src/js/features/file-fold.js @@ -7,7 +7,10 @@ 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); + 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. From 2ea84fa7e905fc5a25998d249199135887c6df05 Mon Sep 17 00:00:00 2001 From: Jimmy Praet Date: Sat, 25 Mar 2023 14:33:01 +0100 Subject: [PATCH 2/5] lint --- web_src/js/features/file-fold.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_src/js/features/file-fold.js b/web_src/js/features/file-fold.js index 4afbf1772399..8321b9b19e05 100644 --- a/web_src/js/features/file-fold.js +++ b/web_src/js/features/file-fold.js @@ -7,7 +7,7 @@ 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); + fileContentBox.setAttribute('data-folded', newFold); if (newFold && fileContentBox.getBoundingClientRect().top < 0) { fileContentBox.scrollIntoView(); } From a08b6c1569814c84b65427b74151651c6039ad2b Mon Sep 17 00:00:00 2001 From: Jimmy Praet Date: Sat, 25 Mar 2023 19:58:54 +0100 Subject: [PATCH 3/5] Add scroll-margin-top --- web_src/css/repository.css | 10 ++++++++++ web_src/css/review.css | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/web_src/css/repository.css b/web_src/css/repository.css index 34c76b15c9b2..4b1a2e5fc876 100644 --- a/web_src/css/repository.css +++ b/web_src/css/repository.css @@ -1853,6 +1853,16 @@ padding-bottom: 5px; } +.repository .diff-file-box { + scroll-margin-top: 47px; /* match .repository .diff-detail-box */ +} + +@media (max-width: 991px) { + .repository .diff-file-box { + scroll-margin-top: 77px; /* match .repository .diff-detail-box */ + } +} + .repository .diff-stats { clear: both; margin-bottom: 5px; diff --git a/web_src/css/review.css b/web_src/css/review.css index 42267b4d2a33..19b694b28cbb 100644 --- a/web_src/css/review.css +++ b/web_src/css/review.css @@ -266,12 +266,12 @@ a.blob-excerpt:hover { display: none; } -.pull.files.diff [id] { +.pull.files.diff .comment { scroll-margin-top: 99px; } @media (max-width: 991px) { - .pull.files.diff [id] { + .pull.files.diff .comment { scroll-margin-top: 130px; } } From 6c8559b2a8c71e45dd8f6257f9182efc673a4cc9 Mon Sep 17 00:00:00 2001 From: Jimmy Praet Date: Thu, 30 Mar 2023 18:22:17 +0200 Subject: [PATCH 4/5] Cleanup after merge --- web_src/css/repository.css | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/web_src/css/repository.css b/web_src/css/repository.css index 418952c98171..440252d47744 100644 --- a/web_src/css/repository.css +++ b/web_src/css/repository.css @@ -1861,8 +1861,16 @@ .diff-file-box { border: 1px solid transparent; 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 */ .diff-file-box .ui.attached.header, .diff-file-box .ui.attached.table { @@ -1871,16 +1879,6 @@ max-width: initial; /* remove fomantic over 100% width */; } -.repository .diff-file-box { - scroll-margin-top: 47px; /* match .repository .diff-detail-box */ -} - -@media (max-width: 991px) { - .repository .diff-file-box { - scroll-margin-top: 77px; /* match .repository .diff-detail-box */ - } -} - .repository .diff-stats { clear: both; margin-bottom: 5px; From 4396af7d1159fce300d901de6384906169714cf3 Mon Sep 17 00:00:00 2001 From: Jimmy Praet Date: Thu, 30 Mar 2023 18:35:24 +0200 Subject: [PATCH 5/5] Remove empty line --- web_src/css/repository.css | 1 - 1 file changed, 1 deletion(-) diff --git a/web_src/css/repository.css b/web_src/css/repository.css index 440252d47744..8922429bd89e 100644 --- a/web_src/css/repository.css +++ b/web_src/css/repository.css @@ -1870,7 +1870,6 @@ } } - /* TODO: this can potentially be made "global" by removing the class prefix */ .diff-file-box .ui.attached.header, .diff-file-box .ui.attached.table {