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 @@
267 // A live change must not shut a menu the reader has open (a run's branch picker, say).267 // A live change must not shut a menu the reader has open (a run's branch picker, say).
268 var dd = how === 'live' ? captureDropdowns() : null;268 var dd = how === 'live' ? captureDropdowns() : null;
269 if (how !== 'live') { closeDropdowns(null); }269 if (how !== 'live') { closeDropdowns(null); }
270+ var oldList = document.querySelector('.ci-run-list');
271+ var listTop = how === 'live' && oldList ? oldList.scrollTop : null;
270 adopt(doc, keepFields, dd, how === 'live' ? captureJobs() : null);272 adopt(doc, keepFields, dd, how === 'live' ? captureJobs() : null);
273+ placeRun(listTop);
271 if (tailAt) {274 if (tailAt) {
272 var nextTail = document.querySelector('[data-live-log]');275 var nextTail = document.querySelector('[data-live-log]');
273 if (nextTail) { nextTail.scrollTop = tailAt.end ? nextTail.scrollHeight : tailAt.top; }276 if (nextTail) { nextTail.scrollTop = tailAt.end ? nextTail.scrollHeight : tailAt.top; }
@@ -282,6 +285,19 @@
282 else { window.scrollTo(0, 0); }285 else { window.scrollTo(0, 0); }
283 }286 }
284 287
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+
285 // The browser takes over where a soft request cannot: a non-HTML answer, or another origin.301 // The browser takes over where a soft request cannot: a non-HTML answer, or another origin.
286 // A GET re-requests the page itself. A POST is never sent again (that would repeat the action):302 // A GET re-requests the page itself. A POST is never sent again (that would repeat the action):
287 // a redirect is followed as a GET, anything else reloads the current page.303 // a redirect is followed as a GET, anything else reloads the current page.
@@ -1091,6 +1107,7 @@
1091 if (!url) { location.assign(href); return; }1107 if (!url) { location.assign(href); return; }
1092 load({ target: withoutHash(url), dest: url, init: GET_INIT, how: 'query', keep: true, post: false, form: null });1108 load({ target: withoutHash(url), dest: url, init: GET_INIT, how: 'query', keep: true, post: false, form: null });
1093 };1109 };
1110+ placeRun();
1094 })();1111 })();
1095 1112
1096 // Code browsing: line selection on blobs and blame, the permalink copy and `y` shortcut, the file1113 // 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: (
4440 list-style: none;4440 list-style: none;
4441 }4441 }
4442 4442
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+
4443 .ci-row {4479 .ci-row {
4444 display: flex;4480 display: flex;
4445 flex-direction: column;4481 flex-direction: column;