Public: anyone can read this; the crew can change it.
On a phone, one tap opens search with the keyboard up and results above it #16749
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/10657-on-a-phone-one-tap-opens-search-with-the → main 0 commits fork 5 threads · 5 unresolved
6 files
changed +107
−5
docs/design/areas/palette.md +4
| @@ -17,3 +17,7 @@ The palette's tell row (`data-tell`, last in the list) sends the typed sentence | ||
| 17 | 17 | ## Keys beside their actions |
| 18 | 18 | |
| 19 | 19 | An action's shortcut takes no room at rest (#8930, changing the "beside the action" rule of #8709). `btn`, `tabs`, the top bar, the feed's Dismiss and the review verdicts carry `data-hint` (`hintAttr()` in `ui.ts`); a `::before` draws it as a tooltip on hover or focus, and over every action while Option is held or after `?` (`html[data-hints]`, set by the shell script; Escape or a second `?` clears it). It is an overlay: nothing moves, and on touch-only screens it is not drawn. `.keyhint`, the inline `<kbd>`, stays only in menu items, where a column holds it; design-lint's `keyhint` rule refuses it elsewhere. A second `?` opens the help, which lists every key. |
| 20 | ||
| 21 | ## The phone's search control (#10657) | |
| 22 | ||
| 23 | The phone search control is the `a[data-palette]` link (`searchDock()` in `src/web/layout.ts`): under 720px a pill sticky to the bottom-right of the viewport (last in the flex-column body, pulled up over the footer's bottom padding so it adds no height), in thumb reach and clear of the home indicator (`env(safe-area-inset-bottom)`), 48px tall, `--accent` text on the card fill with a shadow and no border. The footer carries extra bottom padding so nothing sits under it. It is on every page except a bare one and Talk, which has its own bottom control. It is a link to `/search` carrying `data-palette`, so with the script one tap opens the palette sheet and focuses its input inside the same gesture (the iOS keyboard needs that), and without it the link is the search page. The sheet is full screen (no radius, no border) and sized from `visualViewport`. Hidden from 720px up and in print. | |
src/web/layout.ts +11 −3
| @@ -235,6 +235,8 @@ export interface PageOptions { | ||
| 235 | 235 | * (the board). The overlays stay, so the palette is still one chord away. |
| 236 | 236 | */ |
| 237 | 237 | bare?: boolean; |
| 238 | /** The page has its own bottom control (Talk's message box): no phone search dock under it. */ | |
| 239 | noDock?: boolean; | |
| 238 | 240 | /** A visitor's page: what the bar holds in place of search and the menu. */ |
| 239 | 241 | tools?: Html; |
| 240 | 242 | /** A visitor's page: what the foot holds in place of its usual line. */ |
| @@ -766,6 +768,13 @@ function footer(ctx: Ctx, own?: Html): Html { | ||
| 766 | 768 | </footer>`; |
| 767 | 769 | } |
| 768 | 770 | |
| 771 | /** The phone's search control: a bottom-anchored link in thumb reach on every page. With the | |
| 772 | * script, one tap opens the palette sheet with its input focused (the same gesture, so the keyboard | |
| 773 | * comes up); without it, the link is /search. Hidden from a desktop width by CSS. */ | |
| 774 | function searchDock(): Html { | |
| 775 | return html`<a href=/search data-palette>Search</a>`; | |
| 776 | } | |
| 777 | ||
| 769 | 778 | // ---- the page ---- |
| 770 | 779 | |
| 771 | 780 | |
| @@ -934,9 +943,8 @@ export function page(options: PageOptions, status = 200): Response { | ||
| 934 | 943 | id="main" |
| 935 | 944 | > |
| 936 | 945 | ${flash ? flashToast(flash) : null}${options.body}${asksWhoCan(options.body, flash) ? askFormShell(ctx.url.pathname) : null} |
| 937 | </main> | |
| 938 | ${options.bare ? null : footer(ctx, options.foot)} ${overlays()} | |
| 939 | ${paletteIndex(ctx, options.palette ?? [])}`; | |
| 946 | </main> | |
| 947 | ${options.bare ? null : footer(ctx, options.foot)}${options.bare || options.noDock ? null : searchDock()}${overlays()}${paletteIndex(ctx, options.palette ?? [])}`; | |
| 940 | 948 | |
| 941 | 949 | const own = options.scriptJs ? pageScriptAsset(options.scriptJs, ctx.app.config.dataDir) : undefined; |
| 942 | 950 |
src/web/pages/talk.ts +1 −1
| @@ -695,7 +695,7 @@ async function talkPage(ctx: Ctx, conversation: Conversation, before0: string | | ||
| 695 | 695 | </div> |
| 696 | 696 | ${split ? html`<div class="talk-work">${panel}${pane.html}</div>` : null} |
| 697 | 697 | </div>`; |
| 698 | return page({ ctx, title: conversation.title === "" ? "Talk" : `${conversation.title} · Talk`, body, styleCss: talkCss + paneCss + codePaneCss + (panel === null ? "" : buildCss) + voiceCss, scriptJs: `${talkJs}\n${liveRegionsJs}\n${ownTokenJs}`, description: "Talk to the forge.", wide: true, ...(!split ? {} : { frameSrc: frames }) }); | |
| 698 | return page({ ctx, title: conversation.title === "" ? "Talk" : `${conversation.title} · Talk`, body, styleCss: talkCss + paneCss + codePaneCss + (panel === null ? "" : buildCss) + voiceCss, scriptJs: `${talkJs}\n${liveRegionsJs}\n${ownTokenJs}`, description: "Talk to the forge.", wide: true, noDock: true, ...(!split ? {} : { frameSrc: frames }) }); | |
| 699 | 699 | } |
| 700 | 700 | |
| 701 | 701 | /** |
src/web/style/base.ts +1 −1
| @@ -257,7 +257,7 @@ time[datetime].age { min-width: ${AGE_SLOT_CH}ch; } | ||
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | @media print { |
| 260 | .topbar, .foot, .live-news, .sticky-action, .toast, [data-print-hide] { display: none !important; } | |
| 260 | .topbar, .foot, a[data-palette], .live-news, .sticky-action, .toast, [data-print-hide] { display: none !important; } | |
| 261 | 261 | .card { box-shadow: none; } |
| 262 | 262 | /* An issue or a pull on paper: one column, no chrome (docs/design/areas/print.md). */ |
| 263 | 263 | .shell, .shell-wide { max-width: none; padding: 0; } |
src/web/style/components.ts +14
| @@ -971,6 +971,20 @@ html[data-overlay] { overflow: hidden; } | ||
| 971 | 971 | .palette [data-palette-close] { display: inline-flex; margin-left: auto; min-height: 44px; } |
| 972 | 972 | } |
| 973 | 973 | |
| 974 | /* Phone search control (#10657): sticky at the end of the flex-column body, pulled up over the footer's | |
| 975 | bottom padding so it adds no height; on a short page the footer already sits at the viewport's end. */ | |
| 976 | a[data-palette] { display: none; } | |
| 977 | @media (max-width: 719px) { | |
| 978 | a[data-palette] { | |
| 979 | position: sticky; bottom: max(16px, env(safe-area-inset-bottom)); align-self: flex-end; | |
| 980 | display: inline-flex; align-items: center; min-height: 48px; padding: 0 24px; border-radius: 999px; | |
| 981 | margin: -48px max(16px, env(safe-area-inset-right)) 0 0; | |
| 982 | background: var(--card); color: var(--accent); box-shadow: var(--shadow-2); font-weight: 600; text-decoration: none; | |
| 983 | } | |
| 984 | .foot { padding-bottom: calc(64px + env(safe-area-inset-bottom)); } | |
| 985 | .palette { border-radius: 0; border: 0; } | |
| 986 | } | |
| 987 | ||
| 974 | 988 | /* ---- toast / flash ---- */ |
| 975 | 989 | .toast:not([hidden]) { |
| 976 | 990 | display: flex; align-items: flex-start; gap: 8px; |
test/search-dock.test.ts added +76
| @@ -0,0 +1,76 @@ | ||
| 1 | /** | |
| 2 | * The phone's bottom search control (#10657). Markup: a link to /search carrying data-palette, on | |
| 3 | * every page but a bare one or Talk. Behaviour, in a real Chromium at 390×844: on a page shorter | |
| 4 | * than the viewport the pill is inside the viewport, at least 44 px each way, the topmost thing at | |
| 5 | * its centre (nothing covers it), and a tap opens the palette with its input focused. Skipped, and | |
| 6 | * says so, where no Chromium starts. | |
| 7 | */ | |
| 8 | import { afterAll, beforeAll, expect, test } from "bun:test"; | |
| 9 | import { mkdtemp, rm } from "node:fs/promises"; | |
| 10 | import { tmpdir } from "node:os"; | |
| 11 | import { join } from "node:path"; | |
| 12 | import { createApp, type App } from "../src/app.ts"; | |
| 13 | import { findChromium } from "../src/looks/capture.ts"; | |
| 14 | import { serve, type Servers } from "../src/http/server.ts"; | |
| 15 | import { chromiumRuns, evaluateLoaded } from "./helpers/chrome.ts"; | |
| 16 | import { quietLogs } from "./helpers/globals.ts"; | |
| 17 | ||
| 18 | quietLogs(); | |
| 19 | ||
| 20 | const found = findChromium(); | |
| 21 | const chromium = found !== undefined && chromiumRuns(found) ? found : undefined; | |
| 22 | if (chromium === undefined) console.log("SKIPPING: no chromium that starts on this machine, so the dock is not tapped"); | |
| 23 | ||
| 24 | let dir: string; | |
| 25 | let app: App; | |
| 26 | let servers: Servers; | |
| 27 | let base: string; | |
| 28 | ||
| 29 | beforeAll(async () => { | |
| 30 | dir = await mkdtemp(join(tmpdir(), "forge-search-dock-")); | |
| 31 | app = createApp({ dataDir: dir, port: 0 }); | |
| 32 | servers = await serve(app); | |
| 33 | base = `http://localhost:${String(servers.port)}`; | |
| 34 | }, 30_000); | |
| 35 | afterAll(async () => { | |
| 36 | servers.stop(); | |
| 37 | app.close(); | |
| 38 | await rm(dir, { recursive: true, force: true }); | |
| 39 | }); | |
| 40 | ||
| 41 | test("a page carries the dock, a link to /search the script turns into the sheet", async () => { | |
| 42 | for (const path of ["/pricing", "/explore"]) { | |
| 43 | const page = await (await fetch(`${base}${path}`)).text(); | |
| 44 | expect(page).toContain("<a href=/search data-palette>Search</a>"); | |
| 45 | } | |
| 46 | }); | |
| 47 | ||
| 48 | const TAP = `(async () => { | |
| 49 | const a = document.querySelector('a[data-palette]'); | |
| 50 | const r = a.getBoundingClientRect(); | |
| 51 | const top = document.elementFromPoint(r.left + r.width / 2, r.top + r.height / 2); | |
| 52 | const short = document.documentElement.scrollHeight <= innerHeight + 1; | |
| 53 | a.click(); | |
| 54 | const dlg = document.getElementById("palette"); | |
| 55 | return JSON.stringify({ | |
| 56 | w: r.width, h: r.height, short, | |
| 57 | inside: r.left >= 0 && r.top >= 0 && r.right <= innerWidth && r.bottom <= innerHeight, | |
| 58 | uncovered: top === a, | |
| 59 | open: dlg.open, | |
| 60 | focused: document.activeElement === dlg.querySelector(".palette-input"), | |
| 61 | path: location.pathname, | |
| 62 | }); | |
| 63 | })()`; | |
| 64 | ||
| 65 | for (const scheme of ["light", "dark"] as const) | |
| 66 | test.skipIf(chromium === undefined)(`at 390×844 (${scheme}) a tap on the dock opens the palette with the input focused`, async () => { | |
| 67 | const raw = await evaluateLoaded(chromium!, `${base}/pricing`, { width: 390, height: 844 }, [], TAP, scheme, true); | |
| 68 | const seen = JSON.parse(raw) as Record<string, unknown>; | |
| 69 | expect(seen["w"]).toBeGreaterThanOrEqual(44); | |
| 70 | expect(seen["h"]).toBeGreaterThanOrEqual(44); | |
| 71 | expect(seen["inside"]).toBe(true); | |
| 72 | expect(seen["uncovered"]).toBe(true); | |
| 73 | expect(seen["open"]).toBe(true); | |
| 74 | expect(seen["focused"]).toBe(true); | |
| 75 | expect(seen["path"]).toBe("/pricing"); | |
| 76 | }, 60_000); |
new above
offline
Starts a sentence in lower case ('the sheet is full screen'). It should also say that Talk and bare pages get no dock.