forge
Explore
Log in

Don't you dare go Hollow

Fit the CI runs list to the viewport and scroll it inside its card

Browse files at this commit

a053f44fbaa54106c1936b1090728f9d112b049cAhmet Kaan GümüşParent: cbf0cb1
  • style
    • fit the CI runs list to the viewport and scroll it inside its card
Show full message
💄 style: fit the CI runs list to the viewport and scroll it inside its card
crates/forge-web/assets/nav.jsmodified+17 -0
@@ -267,7 +267,10 @@
267267 // A live change must not shut a menu the reader has open (a run's branch picker, say).
268268 var dd = how === 'live' ? captureDropdowns() : null;
269269 if (how !== 'live') { closeDropdowns(null); }
270+ var oldList = document.querySelector('.ci-run-list');
271+ var listTop = how === 'live' && oldList ? oldList.scrollTop : null;
270272 adopt(doc, keepFields, dd, how === 'live' ? captureJobs() : null);
273+ placeRun(listTop);
271274 if (tailAt) {
272275 var nextTail = document.querySelector('[data-live-log]');
273276 if (nextTail) { nextTail.scrollTop = tailAt.end ? nextTail.scrollHeight : tailAt.top; }
@@ -282,6 +285,19 @@
282285 else { window.scrollTo(0, 0); }
283286 }
284287
288+ // The runs list scrolls inside its card: bring the selected row into view there. scrollIntoView
289+ // would also scroll the page, so the list's own scrollTop is set instead.
290+ function placeRun(keepTop) {
291+ var list = document.querySelector('.ci-run-list');
292+ if (!list) { return; }
293+ if (typeof keepTop === 'number') { list.scrollTop = keepTop; return; }
294+ var row = list.querySelector('.ci-row[aria-current="true"]');
295+ if (!row) { return; }
296+ var l = list.getBoundingClientRect(), r = row.getBoundingClientRect();
297+ if (r.top < l.top) { list.scrollTop += r.top - l.top; }
298+ else if (r.bottom > l.bottom) { list.scrollTop += r.bottom - l.bottom; }
299+ }
300+
285301 // The browser takes over where a soft request cannot: a non-HTML answer, or another origin.
286302 // A GET re-requests the page itself. A POST is never sent again (that would repeat the action):
287303 // a redirect is followed as a GET, anything else reloads the current page.
@@ -1091,6 +1107,7 @@
10911107 if (!url) { location.assign(href); return; }
10921108 load({ target: withoutHash(url), dest: url, init: GET_INIT, how: 'query', keep: true, post: false, form: null });
10931109 };
1110+ placeRun();
10941111 })();
10951112
10961113 // Code browsing: line selection on blobs and blame, the permalink copy and `y` shortcut, the file
style/main.scssmodified+36 -0
@@ -4440,6 +4440,42 @@ $ansi-colours: (
44404440 list-style: none;
44414441 }
44424442
4443+// Desktop: the runs card fits the viewport and sticks under the top bar. Only the rows scroll, so the
4444+// header stays on top and the pager stays at the bottom. The page itself never grows with the list.
4445+@media (min-width: 761px) {
4446+ .ci-side {
4447+ position: sticky;
4448+ top: calc(var(--topbar-h) + 16px);
4449+ display: flex;
4450+ flex-direction: column;
4451+ max-height: calc(100dvh - var(--topbar-h) - 104px);
4452+ }
4453+
4454+ .ci-side-head,
4455+ .ci-scale,
4456+ .ci-next,
4457+ .ci-side .pager {
4458+ flex: none;
4459+ }
4460+
4461+ .ci-run-list {
4462+ flex: 1 1 auto;
4463+ min-height: 0;
4464+ overflow-y: auto;
4465+ overscroll-behavior: contain;
4466+ scrollbar-width: thin;
4467+ }
4468+}
4469+
4470+// Phone: stacked, so the list gets a bounded height instead of running on for dozens of rows.
4471+@media (max-width: 760px) {
4472+ .ci-run-list {
4473+ max-height: 60dvh;
4474+ overflow-y: auto;
4475+ overscroll-behavior: contain;
4476+ }
4477+}
4478+
44434479 .ci-row {
44444480 display: flex;
44454481 flex-direction: column;