forge
Explore
Log in

Don't you dare go Hollow

The CI list, run and job pages show their jobs and log again, which lost all height when the page language dropped their fit pane

Browse files at this commit

949180b7a1fc980cf6eda3feb16e42fcac87f941Ahmet Kaan GümüşParent: 4d91e94
All checks have passed
Show checks
  • fix
    • the CI list, run and job pages show their jobs and log again, which lost all height when the page language dropped their fit pane
    • a phone's CI list no longer collapses its run
    • the runs head keeps the rows' inset and the log tools share one line
    • the logo no longer runs under Explore, which sat on a fixed width the wordmark outgrew
  • feat
    • every search bar is live: results follow typing with focus and caret kept, Enter runs at once, audit log, issues, pulls and code search join in, and the repo head's search moves to the results while typing
    • a branch field waits for change, since half a name is a 404
    • sort on issues and pulls applies on change
    • scripts/audit/measure.ts reports a pane that lost its height
Show full message
🐛 fix: the CI list, run and job pages show their jobs and log again, which lost all height when the page language dropped their fit pane; a phone's CI list no longer collapses its run; the runs head keeps the rows' inset and the log tools share one line; the logo no longer runs under Explore, which sat on a fixed width the wordmark outgrew; ✨ feat: every search bar is live: results follow typing with focus and caret kept, Enter runs at once, audit log, issues, pulls and code search join in, and the repo head's search moves to the results while typing; a branch field waits for change, since half a name is a 404; sort on issues and pulls applies on change; scripts/audit/measure.ts reports a pane that lost its height
crates/forge-web/assets/nav.jsmodified+31 -0
@@ -361,6 +361,9 @@
361361 // A fit pane keeps its scroll when the page stays put (a live change, a post, a filter), by its place in the page.
362362 var paneTops = how === 'live' || how === 'post' || how === 'query' ? paneScrolls() : null;
363363 var bars = how === 'live' ? barSegments() : null;
364+ var jump = liveJump && liveJump.path === dest.pathname ? liveJump.input : null;
365+ var jumped = jump ? jump.value : '';
366+ liveJump = null;
364367 var steps = captureSteps();
365368 adopt(doc, keepFields, dd, how === 'live' ? captureJobs() : null);
366369 restoreSteps(steps);
@@ -375,6 +378,7 @@
375378 else if (how === 'post' || how === 'query') { history.replaceState(null, '', dest.href); }
376379 shown = dest.pathname + dest.search;
377380 if (how === 'nav' || how === 'pop') { focusMain(); }
381+ if (jump) { landSearch(jumped); }
378382 if (how !== 'live' && placeHash(dest.hash)) { return; }
379383 if (how === 'live' && placeAnchor(at)) { return; }
380384 if (how === 'post' || how === 'query' || how === 'live') { window.scrollTo(x, y); }
@@ -1552,6 +1556,15 @@
15521556 var q = new URLSearchParams(data).toString();
15531557 var dest = withoutHash(url);
15541558 dest.search = q ? '?' + q : '';
1559+ // Enter in a live field on its own results page runs the search now and leaves the reader typing.
1560+ var typing = document.activeElement;
1561+ if (typing && typing.form === form && typing.hasAttribute('data-live-search') && url.pathname === location.pathname) {
1562+ clearTimeout(searchTimer);
1563+ searchTimer = null;
1564+ if (dest.pathname + dest.search === shown) { pending.delete(form); return; }
1565+ load({ target: dest, dest: dest, init: GET_INIT, how: 'query', keep: true, post: false, form: form });
1566+ return;
1567+ }
15551568 saveScroll();
15561569 load({ target: dest, dest: dest, init: GET_INIT, how: 'nav', keep: false, post: false, form: form });
15571570 return;
@@ -1586,7 +1599,18 @@
15861599 // Search as you type: a search field marked data-live-search refetches its GET form 250 ms after
15871600 // the last keystroke and swaps the page in place, with no history entry and the field's focus and
15881601 // caret kept. A newer request drops an older answer. The submit button stays as the no-JS path.
1602+ // A field whose results are on another page (the repo head's code search) goes there once it has
1603+ // text: that page's field takes over with what was typed, so the reader never stops typing.
15891604 var searchTimer = null;
1605+ var liveJump = null;
1606+ function landSearch(value) {
1607+ var el = document.querySelector('[data-live-search]');
1608+ if (!el) { return; }
1609+ el.value = value;
1610+ el.focus({ preventScroll: true });
1611+ el.setSelectionRange(value.length, value.length);
1612+ if (value !== el.defaultValue) { el.dispatchEvent(new Event('input', { bubbles: true })); }
1613+ }
15901614 function liveSearch(input) {
15911615 var el = input.isConnected ? input : document.querySelector('[data-live-search]');
15921616 var form = el && el.form;
@@ -1596,6 +1620,13 @@
15961620 var q = new URLSearchParams(new FormData(form)).toString();
15971621 dest.search = q ? '?' + q : '';
15981622 if (dest.pathname + dest.search === shown) { return; }
1623+ if (dest.pathname !== location.pathname) {
1624+ if (!el.value.trim()) { return; }
1625+ liveJump = { path: dest.pathname, input: el };
1626+ saveScroll();
1627+ load({ target: dest, dest: dest, init: GET_INIT, how: 'nav', keep: false, post: false, form: null });
1628+ return;
1629+ }
15991630 load({ target: dest, dest: dest, init: GET_INIT, how: 'query', keep: true, post: false, form: null });
16001631 }
16011632 document.addEventListener('input', function (e) {
crates/forge-web/src/pages/audit_log.rsmodified+2 -2
@@ -139,8 +139,8 @@ async fn admin_audit_view(
139139 <form method="get" action="/admin/audit">
140140 <div class="plain-search">
141141 <label class="sr-only" for="audit-actor">(g::t(lang, K::ActorUsername))</label>
142- <input id="audit-actor" type="text" name="actor" value=(actor.as_str()) autocomplete="off">
143- <button type="submit" class="act">(g::t(lang, K::Filter))</button>
142+ <input id="audit-actor" type="search" name="actor" value=(actor.as_str()) placeholder=(g::t(lang, K::ActorUsername)) data-live-search="" autocomplete="off">
143+ <button type="submit" class="sr-only">(g::t(lang, K::Filter))</button>
144144 </div>
145145 <div class="sub">
146146 <label>
crates/forge-web/src/pages/ci_job.rsmodified+1 -1
@@ -435,7 +435,7 @@ async fn job_body(
435435 ) -> Result<impl View> {
436436 Ok(view! {
437437 repo_head(head: RepoHead { live: String::new(), ..head })
438- <div data-live=(live.as_str()) data-live-state=(job.fingerprint.as_str()) class="ci-job">
438+ <div data-live=(live.as_str()) data-live-state=(job.fingerprint.as_str()) class="ci-job fit-pane">
439439 <header class="ci-tl-head">
440440 <div class="ci-tl-headmain">
441441 <div class="ci-tl-line">
crates/forge-web/src/pages/ci_runs.rsmodified+2 -2
@@ -2250,7 +2250,7 @@ async fn runs_body(
22502250 <p class="state" role="status">(text)</p>
22512251 }
22522252 }
2253- <div data-live=(live.as_deref()) class="ci-split" data-now=(now_unix().to_string()) data-fm=(fm.as_str()) data-fs=(fs.as_str())>
2253+ <div data-live=(live.as_deref()) class="ci-split fit-pane" data-now=(now_unix().to_string()) data-fm=(fm.as_str()) data-fs=(fs.as_str())>
22542254 <svg class="ci-defs" width="0" height="0" focusable="false" aria-hidden="true">
22552255 <defs>
22562256 <pattern id="ci-hatch" width="6" height="6" patternUnits="userSpaceOnUse" patternTransform="rotate(45)">
@@ -2654,7 +2654,7 @@ async fn run_body(
26542654 <p class="state" role="status">(text)</p>
26552655 }
26562656 }
2657- <div data-live=(live.as_deref()) class="ci-split" data-now=(now_unix().to_string()) data-fm=(fm.as_str()) data-fs=(fs.as_str())>
2657+ <div data-live=(live.as_deref()) class="ci-split fit-pane" data-now=(now_unix().to_string()) data-fm=(fm.as_str()) data-fs=(fs.as_str())>
26582658 <svg class="ci-defs" width="0" height="0" focusable="false" aria-hidden="true">
26592659 <defs>
26602660 <pattern id="ci-hatch" width="6" height="6" patternUnits="userSpaceOnUse" patternTransform="rotate(45)">
crates/forge-web/src/pages/code_search.rsmodified+7 -8
@@ -212,29 +212,28 @@ async fn search_page(cx: &Cx) -> Result<impl View> {
212212 <div class="search-page">
213213 <form method="get" action=(action.as_str()) class="search-form" role="search">
214214 <div class="plain-search">
215- <input type="search" name="q" value=(q.as_str()) placeholder=(g::t(lang, K::SearchCodePlaceholder)) aria-label=(g::t(lang, K::SearchCodePlaceholder))>
215+ <input type="search" name="q" value=(q.as_str()) data-live-search="" autocomplete="off" placeholder=(g::t(lang, K::SearchCodePlaceholder)) aria-label=(g::t(lang, K::SearchCodePlaceholder))>
216+ <button type="submit" class="sr-only">(g::t(lang, K::SearchButton))</button>
216217 </div>
217218 <div class="field-pair">
218219 <div class="field">
219220 <label for="search-ref">(g::t(lang, K::RefField))</label>
220- <input id="search-ref" type="text" name="ref" value=(ref_value.as_str()) placeholder=(ctx.repo.default_branch.as_str())>
221+ // Not live: a half-typed branch name is a 404 page. It searches on leaving the field.
222+ <input id="search-ref" type="text" name="ref" value=(ref_value.as_str()) placeholder=(ctx.repo.default_branch.as_str()) data-autosubmit=(true)>
221223 </div>
222224 <div class="field">
223225 <label for="search-path">(g::t(lang, K::PathField))</label>
224- <input id="search-path" type="text" name="path" value=(path_value.as_str()) placeholder="src/**/*.rs">
226+ <input id="search-path" type="text" name="path" value=(path_value.as_str()) placeholder="src/**/*.rs" data-live-search="">
225227 </div>
226228 </div>
227229 <label class="switch">
228- <input type="checkbox" name="case" value="1" checked=(match_case)>
230+ <input type="checkbox" name="case" value="1" checked=(match_case) data-autosubmit=(true)>
229231 <span>(g::t(lang, K::MatchCase))</span>
230232 </label>
231233 <label class="switch">
232- <input type="checkbox" name="regex" value="1" checked=(regex)>
234+ <input type="checkbox" name="regex" value="1" checked=(regex) data-autosubmit=(true)>
233235 <span>(g::t(lang, K::RegexOption))</span>
234236 </label>
235- <div class="acts">
236- <button type="submit" class="primary">(g::t(lang, K::SearchButton))</button>
237- </div>
238237 </form>
239238 if empty_repo {
240239 <p class="state">(empty_message.as_str())</p>
crates/forge-web/src/pages/issues_list.rsmodified+2 -2
@@ -523,11 +523,11 @@ async fn issues_list_page(cx: &Cx) -> Result<impl View> {
523523 <input type="hidden" name="author" value=(sel.author.as_str())>
524524 <input type="hidden" name="assignee" value=(sel.assignee.as_str())>
525525 <div class="plain-search">
526- <input type="search" name="q" value=(search_value.as_str()) placeholder=(g::t(lang, K::SearchTitles)) aria-label=(g::t(lang, K::SearchTitles)) maxlength="256">
526+ <input type="search" name="q" value=(search_value.as_str()) data-live-search="" autocomplete="off" placeholder=(g::t(lang, K::SearchTitles)) aria-label=(g::t(lang, K::SearchTitles)) maxlength="256">
527527 <button type="submit" class="sr-only">(g::t(lang, K::Search))</button>
528528 </div>
529529 <div class="sub">
530- <select name="sort" aria-label=(g::t(lang, K::Sort))>
530+ <select name="sort" aria-label=(g::t(lang, K::Sort)) data-autosubmit=(true)>
531531 for option in sort_options.iter() {
532532 <option value=(option.value) selected=(option.selected)>(option.label)</option>
533533 }
crates/forge-web/src/pages/pulls_list.rsmodified+2 -2
@@ -287,7 +287,7 @@ async fn pulls_list_page(cx: &Cx) -> Result<impl View> {
287287 <input type="hidden" name="author" value=(sel.author.as_str())>
288288 <input type="hidden" name="assignee" value=(sel.assignee.as_str())>
289289 <div class="plain-search">
290- <input type="search" name="q" value=(search_value.as_str()) placeholder=(g::t(lang, K::SearchTitles)) aria-label=(g::t(lang, K::SearchTitles)) maxlength="256">
290+ <input type="search" name="q" value=(search_value.as_str()) data-live-search="" autocomplete="off" placeholder=(g::t(lang, K::SearchTitles)) aria-label=(g::t(lang, K::SearchTitles)) maxlength="256">
291291 <button type="submit" class="sr-only">(g::t(lang, K::Search))</button>
292292 </div>
293293 <div class="sub">
@@ -296,7 +296,7 @@ async fn pulls_list_page(cx: &Cx) -> Result<impl View> {
296296 <option value="true" selected=(draft_sel == "true")>(g::t(lang, K::DraftOnly))</option>
297297 <option value="false" selected=(draft_sel == "false")>(g::t(lang, K::DraftReadyOnly))</option>
298298 </select>
299- <select name="sort" aria-label=(g::t(lang, K::SortLabel))>
299+ <select name="sort" aria-label=(g::t(lang, K::SortLabel)) data-autosubmit=(true)>
300300 for option in sort_options.iter() {
301301 <option value=(option.value) selected=(option.selected)>(option.label)</option>
302302 }
crates/forge-web/src/pages/repo.rsmodified+1 -1
@@ -215,7 +215,7 @@ pub async fn repo_head(head: RepoHead) -> Result<impl View> {
215215 repo_tabs(owner: owner.clone(), repo: name.clone(), default_branch: default_branch.clone(), active: active.clone(), can_admin: can_admin, lang: lang, open_issues: Some(open_issues), open_pulls: Some(open_pulls), discussions: discussions, wiki: wiki, security: security)
216216 if !hide_search && active == "code" {
217217 <form method="get" action=(search_action.as_str()) class="plain-search" role="search">
218- <input type="search" name="q" placeholder=(search_label) aria-label=(search_label) autocomplete="off">
218+ <input type="search" name="q" data-live-search="" placeholder=(search_label) aria-label=(search_label) autocomplete="off">
219219 </form>
220220 }
221221 </section>
crates/forge-web/src/views/mod.rsmodified+11 -9
@@ -692,14 +692,16 @@ pub async fn shell(
692692 </head>
693693 <body data-link-restarting=(lk::t(lang, LinkKey::Restarting)) data-link-back=(lk::t(lang, LinkKey::BackSubmit)) data-done-saved=(lk::t(lang, LinkKey::Saved)) data-done-ok=(lk::t(lang, LinkKey::Done)) data-draft-restored=(lk::t(lang, LinkKey::DraftRestored)) data-draft-discard=(lk::t(lang, LinkKey::DraftDiscard)) data-select-filter=(lk::t(lang, LinkKey::SelectFilter)) data-select-none=(lk::t(lang, LinkKey::SelectNone)) data-signed-in=(signed_in.then(|| "true".to_owned())) data-tree-w=(tree_w) data-corner-pos=(corner_pos)>
694694 <header class="topbar">
695- <a class="wordmark" href="/">
696- <svg class="ico wordmark-mark" viewBox="0 0 24 24" aria-hidden="true"><path d="M5 19c0-7 5-12 14-13-1 9-6 14-13 14"/><path d="M5 19l6-6"/></svg>
697- "forge"
698- </a>
699- <a class="top-explore" href="/explore" title=(explore_label) aria-label=(explore_label)>
700- <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="m15.5 8.5-2 5-5 2 2-5z"/></svg>
701- <span>(explore_label)</span>
702- </a>
695+ <div class="top-start">
696+ <a class="wordmark" href="/">
697+ <svg class="ico wordmark-mark" viewBox="0 0 24 24" aria-hidden="true"><path d="M5 19c0-7 5-12 14-13-1 9-6 14-13 14"/><path d="M5 19l6-6"/></svg>
698+ "forge"
699+ </a>
700+ <a class="top-explore" href="/explore" title=(explore_label) aria-label=(explore_label)>
701+ <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="m15.5 8.5-2 5-5 2 2-5z"/></svg>
702+ <span>(explore_label)</span>
703+ </a>
704+ </div>
703705 <nav class="pathbar" aria-label=(mi::t(lang, MK::BreadcrumbNav))>
704706 if signed_in {
705707 <svg class="ico pathbar-ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg>
@@ -754,7 +756,7 @@ pub async fn shell(
754756 } else {
755757 <form class="top-search" role="search" method="get" action="/explore">
756758 <svg class="ico top-search-icon" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg>
757- <input type="search" name="q" placeholder=(search_label) aria-label=(search_label)>
759+ <input type="search" name="q" data-live-search="" autocomplete="off" placeholder=(search_label) aria-label=(search_label)>
758760 </form>
759761 <form class="theme-form" method="post" action="/-/theme">
760762 if let Some(csrf) = theme_csrf {
scripts/audit/measure.tsmodified+7 -0
@@ -154,6 +154,13 @@ const CHECK = `(() => {
154154 if (t && t.getBoundingClientRect().top >= i.bottom - 1) bad.push('tick above its label: ' + t.textContent.trim().slice(0, 30));
155155 }
156156 }
157+ // A pane that lost its height: its content is there and nothing of it can be seen.
158+ for (const e of main.querySelectorAll('div, section, ul, ol, pre, article')) {
159+ const r = e.getBoundingClientRect();
160+ if (r.height >= 4 || r.width < 40 || e.closest('.sr-only, [hidden]') || !e.innerText?.trim()) continue;
161+ if (e.children.length === 1 && e.firstElementChild.matches('.sr-only')) continue;
162+ if (getComputedStyle(e).display !== 'none') bad.push('collapsed: ' + e.tagName + '.' + String(e.className).slice(0, 40) + ' height ' + Math.round(r.height));
163+ }
157164 for (const b of main.querySelectorAll('.acts > button:not(.act, .primary), .sec button.danger:not(.act)')) bad.push('button where a text link belongs: ' + b.textContent.trim().slice(0, 30));
158165 return [...new Set(bad)];
159166 })()`;
style/_min.scssmodified+13 -8
@@ -30,6 +30,14 @@
3030 gap: 0;
3131 }
3232
33+// The logo and Explore. Both take the width of their own text, so neither runs under the other.
34+.top-start {
35+ display: flex;
36+ flex: none;
37+ align-items: center;
38+ gap: 4px;
39+}
40+
3341 .top-explore {
3442 display: inline-flex;
3543 align-items: center;
@@ -60,15 +68,12 @@
6068 border-bottom: 1px solid var(--border);
6169 }
6270
63- .wordmark {
64- width: 66px;
65- }
66-
67- // The logo and Explore fill the room up to the edge, so the path bar stands on it.
68- .top-explore {
69- width: calc(var(--edge) - 24px - 66px - 8px);
71+ // The logo and Explore hold the room up to the edge, so the path bar stands on it.
72+ .top-start {
7073 box-sizing: border-box;
71- margin-right: 8px;
74+ width: calc(var(--edge) - 24px);
75+ min-width: max-content;
76+ padding-right: 6px;
7277 }
7378
7479 .pathbar,
style/_min_ci.scssmodified+26 -0
@@ -12,6 +12,24 @@
1212 margin-left: 0;
1313 }
1414
15+// Links and buttons in the log's tools sit on one line, whatever element each one is.
16+.ci-tl-tools {
17+ gap: 14px;
18+
19+ .act {
20+ align-self: center;
21+ margin: 0;
22+ font-size: 14px;
23+ line-height: 20px;
24+ }
25+}
26+
27+// The runs pane has a border: its head keeps the same inset as the rows under it.
28+.ci-split > .ci-side .ci-side-head {
29+ padding: 8px 14px;
30+ margin-bottom: 0;
31+}
32+
1533 // An action that opens in place takes the title line's full width when it needs it.
1634 .ci-tl-line {
1735 flex-wrap: wrap;
@@ -30,3 +48,11 @@
3048 letter-spacing: 0;
3149 text-transform: none;
3250 }
51+
52+// On a phone the page scrolls, so the jobs and the log take their own height. The list's run pane
53+// has no fixed height to share out, and a pane sized from it would be nothing.
54+@media (max-width: 899px) {
55+ .ci-split.fit-pane > .ci-detail > .ci-tl-main {
56+ flex: none;
57+ }
58+}