From a053f44fbaa54106c1936b1090728f9d112b049c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Tue, 20 Oct 2026 17:51:05 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=84=20style:=20fit=20the=20CI=20runs?= =?UTF-8?q?=20list=20to=20the=20viewport=20and=20scroll=20it=20inside=20it?= =?UTF-8?q?s=20card?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/forge-web/assets/nav.js | 17 ++++++++++++++++ style/main.scss | 36 ++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/crates/forge-web/assets/nav.js b/crates/forge-web/assets/nav.js index 53dac60..a1a021c 100644 --- a/crates/forge-web/assets/nav.js +++ b/crates/forge-web/assets/nav.js @@ -267,7 +267,10 @@ // A live change must not shut a menu the reader has open (a run's branch picker, say). var dd = how === 'live' ? captureDropdowns() : null; if (how !== 'live') { closeDropdowns(null); } + var oldList = document.querySelector('.ci-run-list'); + var listTop = how === 'live' && oldList ? oldList.scrollTop : null; adopt(doc, keepFields, dd, how === 'live' ? captureJobs() : null); + placeRun(listTop); if (tailAt) { var nextTail = document.querySelector('[data-live-log]'); if (nextTail) { nextTail.scrollTop = tailAt.end ? nextTail.scrollHeight : tailAt.top; } @@ -282,6 +285,19 @@ else { window.scrollTo(0, 0); } } + // The runs list scrolls inside its card: bring the selected row into view there. scrollIntoView + // would also scroll the page, so the list's own scrollTop is set instead. + function placeRun(keepTop) { + var list = document.querySelector('.ci-run-list'); + if (!list) { return; } + if (typeof keepTop === 'number') { list.scrollTop = keepTop; return; } + var row = list.querySelector('.ci-row[aria-current="true"]'); + if (!row) { return; } + var l = list.getBoundingClientRect(), r = row.getBoundingClientRect(); + if (r.top < l.top) { list.scrollTop += r.top - l.top; } + else if (r.bottom > l.bottom) { list.scrollTop += r.bottom - l.bottom; } + } + // The browser takes over where a soft request cannot: a non-HTML answer, or another origin. // A GET re-requests the page itself. A POST is never sent again (that would repeat the action): // a redirect is followed as a GET, anything else reloads the current page. @@ -1091,6 +1107,7 @@ if (!url) { location.assign(href); return; } load({ target: withoutHash(url), dest: url, init: GET_INIT, how: 'query', keep: true, post: false, form: null }); }; + placeRun(); })(); // Code browsing: line selection on blobs and blame, the permalink copy and `y` shortcut, the file diff --git a/style/main.scss b/style/main.scss index 779ad58..2161b7c 100644 --- a/style/main.scss +++ b/style/main.scss @@ -4440,6 +4440,42 @@ $ansi-colours: ( list-style: none; } +// Desktop: the runs card fits the viewport and sticks under the top bar. Only the rows scroll, so the +// header stays on top and the pager stays at the bottom. The page itself never grows with the list. +@media (min-width: 761px) { + .ci-side { + position: sticky; + top: calc(var(--topbar-h) + 16px); + display: flex; + flex-direction: column; + max-height: calc(100dvh - var(--topbar-h) - 104px); + } + + .ci-side-head, + .ci-scale, + .ci-next, + .ci-side .pager { + flex: none; + } + + .ci-run-list { + flex: 1 1 auto; + min-height: 0; + overflow-y: auto; + overscroll-behavior: contain; + scrollbar-width: thin; + } +} + +// Phone: stacked, so the list gets a bounded height instead of running on for dozens of rows. +@media (max-width: 760px) { + .ci-run-list { + max-height: 60dvh; + overflow-y: auto; + overscroll-behavior: contain; + } +} + .ci-row { display: flex; flex-direction: column;