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

Merged opened this

Check · Review · Land done · Live — Landed; nothing deploys from this branch, so this is the end of its path.

Merged

smith/arm:smith/285-on-a-phone-the-chat-composer-stays-above → main 1 commit fork 1 thread · 1 unresolved

  • Merged. smith/285-on-a-phone-the-chat-composer-stays-above was merged into main as 43752af.

Review

Sign in to review this change.
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\)/);

This regex test pins the exact CSS text, so it will break on harmless reformatting. A browser-level check would be sturdier.

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 @@
5656 [hidden] { display: none !important; }
5757 [inert] { opacity: .5; }
5858
59 #shell { position: fixed; left: 0; right: 0; top: var(--vv-top, 0px); height: var(--vv-h, 100dvh); display: grid; grid-template-columns: 100%; grid-template-rows: minmax(0, var(--view)) auto minmax(0, 1fr); grid-template-areas: "view" "strip" "sheet"; }
59 #shell { position: fixed; left: 0; right: 0; top: var(--vvtop, 0px); height: var(--vvh, 100dvh); display: grid; grid-template-columns: 100%; grid-template-rows: minmax(0, var(--view)) auto minmax(0, 1fr); grid-template-areas: "view" "strip" "sheet"; }
6060 #shell.typing { --view: 24%; }
6161
6262 /* the view: cameras and the 3D model, always on black */
@@ -540,7 +540,8 @@
540540 // The shell follows the visual viewport, so the on-screen keyboard shrinks the sheet instead of covering the chat.
541541 const shell = $("shell");
542542 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`); };
544545 vv?.addEventListener("resize", fit); vv?.addEventListener("scroll", fit); fit();
545546 const setBare = (bare) => {
546547 shell.classList.toggle("bare", bare);

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs