Public: anyone can read this; the crew can change it.
Migrated from github.com/Trevato/SO-ARM100
workbenchthis machine
On a phone the chat composer stays above the keyboard, and typing never zooms the page #308
Check · Review · Land done · Live — Landed; nothing deploys from this branch, so this is the end of its path.
smith/arm:smith/285-on-a-phone-the-chat-composer-stays-above → main 1 commit fork 1 thread · 1 unresolved
2 files
changed +27
−2
Software/so101/src/composer-viewport.test.ts added +24
| @@ -0,0 +1,24 @@ | ||
| 1 | import { expect, test } from "bun:test"; | |
| 2 | ||
| 3 | // The chat composer on a phone, read rather than rendered (no browser here): the page tracks the visual viewport in | |
| 4 | // --vvh, pins the shell, and so the composer, to its bottom, and never lets typing zoom the page. | |
| 5 | const html = await Bun.file(new URL("./viewer.html", import.meta.url)).text(); | |
| 6 | ||
| 7 | test("the viewport meta resizes content for the keyboard", () => { | |
| 8 | expect(html).toMatch(/<meta name="viewport"[^>]*interactive-widget=resizes-content/); | |
| 9 | }); | |
| 10 | ||
| 11 | test("visualViewport resize and scroll set --vvh", () => { | |
| 12 | expect(html).toMatch(/vv\?\.addEventListener\("resize", fit\)/); | |
| 13 | expect(html).toMatch(/vv\?\.addEventListener\("scroll", fit\)/); | |
| 14 | expect(html).toContain('setProperty("--vvh"'); | |
| 15 | }); | |
| 16 | ||
| 17 | test("the shell is fixed to the visual viewport, so the composer sits at its bottom", () => { | |
| 18 | expect(html).toMatch(/#shell \{ position: fixed;[^}]*top: var\(--vvtop, 0px\); height: var\(--vvh, 100dvh\)/); | |
| 19 | }); | |
| 20 | ||
| 21 | test("the composer's input is at least 16px, so iOS does not zoom", () => { | |
| 22 | const rule = html.match(/select, input\[type=number\], input\[type=text\] \{([^}]*)\}/)?.[1] ?? ""; | |
| 23 | expect(Number(rule.match(/font-size: (\d+)px/)?.[1])).toBeGreaterThanOrEqual(16); | |
| 24 | }); |
Software/so101/src/viewer.html +3 −2
| @@ -56,7 +56,7 @@ | ||
| 56 | 56 | [hidden] { display: none ; } |
| 57 | 57 | [inert] { opacity: .5; } |
| 58 | 58 | |
| 59 | #shell { position: fixed; left: 0; right: 0; top: var(, 0px); height: var(, 100dvh); display: grid; grid-template-columns: 100%; grid-template-rows: minmax(0, var()) auto minmax(0, 1fr); grid-template-areas: "view" "strip" "sheet"; } | |
| 59 | #shell { position: fixed; left: 0; right: 0; top: var(, 0px); height: var(, 100dvh); display: grid; grid-template-columns: 100%; grid-template-rows: minmax(0, var()) auto minmax(0, 1fr); grid-template-areas: "view" "strip" "sheet"; } | |
| 60 | 60 | #shell.typing { : 24%; } |
| 61 | 61 | |
| 62 | 62 | /* the view: cameras and the 3D model, always on black */ |
| @@ -540,7 +540,8 @@ | ||
| 540 | 540 | // The shell follows the visual viewport, so the on-screen keyboard shrinks the sheet instead of covering the chat. |
| 541 | 541 | const shell = $("shell"); |
| 542 | 542 | const vv = window.visualViewport; |
| 543 | const fit = () => { if (!vv) return; shell.style.setProperty("--vv-h", `${vv.height}px`); shell.style.setProperty("--vv-top", `${vv.offsetTop}px`); }; | |
| 543 | const root = document.documentElement.style; | |
| 544 | const fit = () => { if (!vv) return; root.setProperty("--vvh", `${vv.height}px`); root.setProperty("--vvtop", `${vv.offsetTop}px`); }; | |
| 544 | 545 | vv?.addEventListener("resize", fit); vv?.addEventListener("scroll", fit); fit(); |
| 545 | 546 | const setBare = (bare) => { |
| 546 | 547 | shell.classList.toggle("bare", bare); |
new above
offline
This regex test pins the exact CSS text, so it will break on harmless reformatting. A browser-level check would be sturdier.