oficina / docs Public

Phone web P2: the Format sheet and the quick format bar open review pending

On branch feat/phone-format

Phone web P2: the Format sheet and the quick format bar

Slice P2 of the phone web design (design/phone-web e058917, Paul's approval of 11-28). Branch feat/phone-format from main ec28e8f; one commit, 218c148.

What changes (on a phone: below 704px, or a short coarse screen)

  • The Format sheet. The inspector becomes a half-height bottom sheet (50dvh, 28px top corners). From top to bottom: - a grabber, "Format" and ×; - the paragraph styles as chips, each drawn at its own size and weight, pressed for the selection's style; - the font, with its size between − and + steps; - B / I / code and the three alignments; - the lists; - More: outdent, indent, clear formatting.
  • Opening and closing. Aa in the bar, or Aa on the capsule, opens it. - It closes with ×, Escape, a swipe down on its head, or Aa again. - Opening it puts the keyboard away and keeps the selection drawn, as a ProseMirror decoration, because the blur would otherwise hide it. The page scrolls the selection clear of the sheet. - Chips and steps apply without bringing the keyboard back. - × gives the keyboard back if it was up. - Focus goes into the sheet when it is opened from a keyboard, and comes back to Aa afterwards.
  • The quick format bar (answer 2) is a capsule 8px above the on-screen keyboard while the document has the caret: Aa · B I · bullets, numbers, quote · Hide keyboard. - It is placed from visualViewport, measured from the top, as the bar is. - With no visualViewport it is a strip under the bar. - Its buttons are synced like the toolbar (disabled, pressed). - The editor's scrollMargin grows by its height, so the caret is never under it.
  • P1 finding 18, fixed. With the keyboard up, Mobile Safari scrolled the sticky bar out of view. The bar now follows visualViewport.offsetTop, and folds while the keyboard is up.
  • From 704px nothing changes. The chips live inside the Style group, not in a group of their own before it, so every later group keeps the neighbours it has on the desktop ([docs-toolbar-group] + [docs-toolbar-group]). iPad's Format popover is P5.

Found and fixed while checking

  • Capsule hidden behind Safari's accessory bar. In a short document scrolled with the keyboard up, Mobile Safari's innerHeight reads 109px short of the layout viewport (714 becomes 605). A capsule placed from the bottom then fell behind Safari's accessory bar. It is now placed from the top. - Test: the fake viewport in TestTheFormatSheetAndTheQuickBar reproduces the short innerHeight. It failed before the fix (the capsule's foot at 830, not 721).
  • Swipe to close. It didn't work on a real touch, because the sheet's own scroll took the drag. Fixed with touch-action: none on the head and a check on release too. - Test: a CDP touch drag. It failed before the fix.
  • Desktop inspector. A first cut put the chips first in the toolbar, which restyled the Style group on the desktop and drew the chips and More there. Caught by the desktop pixel comparison. - Test: a 1280 step asserts nothing sheet-only is drawn and the font and its size share a line. It failed, then passed.
  • The + step wrapped onto its own line at 360 to 430. Fixed by giving the font picker a 0 flex-basis. - Test: an assertion that the four controls share one line. It failed at 390, then passed.

Evidence

  • Unit tests. TestAaControlsTheFormatSheet checks that the bar's Aa and the capsule's Aa control docs-inspector, and that a reader has no capsule. The full internal/docs unit suite, go vet -tags browser, and the toolbar, toolbar-roving and menu node tests are green. The bundle is unchanged by a rebuild (editor.117990f5f1de95bd.js).
  • Browser test TestTheFormatSheetAndTheQuickBar (new; Chromium, touch, 390×844, with a scripted visualViewport). It checks: - no capsule without a keyboard; - with a keyboard, the capsule 8px above it, 48px tall, and the bar folded; - a visual viewport scrolled 200px, then one with innerHeight short; - B pressed with the caret kept; - with a selection, Aa: a half-height sheet, the keyboard gone, the selection drawn, no capsule; - the four controls on one line; - Heading 2 and a step applied with no keyboard (the steps' only test: 12 up to 14); - × gives the keyboard back; - Hide keyboard; - the bar's Aa, then Escape; - the swipe; - 1280 unchanged; - no visualViewport: the strip under the bar.
  • Other browser tests, all passing: - Chromium and WebKit: TestEnginesTheI2Layout. The 390 leg now asserts that Aa opens the sheet, 40–60% of the screen tall and at its foot. - Chromium: TestThePhoneDocumentScreen, TestARenameThatFailsStaysOnThePage, TestNoZoomOnTap, TestEveryScreenKeepsTheRhythm and TestFontTheStatusNeverCoversText.
  • Desktop. Fresh seeded dev servers for main ec28e8f and this branch, at 1280, light and dark. The page at rest, each of the six menus open, and the caret in the text: pixel-identical, 16 of 16.
  • Mobile Safari with real taps (iOS 27.0 simulator). Script focus doesn't raise the keyboard there, and this shell can't click the Simulator window, so a scratch XCUITest drove Safari. Its taps are real touches. I booted the shut-down "Kass UI iOS" device myself and shut down only that device; the other session's iPhone 18 Pro was not touched. The scratch apps were uninstalled, and nothing of the harness is in the branch. - The keyboard really opens (its frame is at y=590 of 874). - The capsule sits 8px above the visual viewport. In iOS 27, Safari's own address pill and the ^ ∨ ✓ accessory bar sit between the visual viewport and the keyboard, and the visual viewport ends above them. So the capsule sits above Safari's chrome, not on the keys. That is as close as a page can get. - Scrolling 221px with the keyboard up: the bar stays at the top of the screen, folded. - B keeps the keyboard. - A double-tapped word, then Aa: the sheet, the keyboard goes, and the word stays highlighted. - Heading 2 and + apply with the keyboard still down. - × brings the keyboard back. - Hide keyboard works. - The bar's Aa opens the sheet, and a swipe down closes it. - The same in dark mode, and on the Arabic document. The Arabic run is the one that found the short innerHeight; it passes now.
  • Screenshots in polish-audit/docs-phone-web/build/p2-docs/: - chromium/: 360, 390, 430, 768, 1024 (touch) and 1280; light and dark; English, Arabic and Russian; at rest, the sheet, and the capsule (probes.json: no sideways scroll, the sheet half the screen, tools at least 44px). - mobile-safari/: light, dark and ar runs, with report.jsonl, the XCUITest's lines and its source. - desktop-vs-main/: the 32 PNGs.

Compared with the mock-up, and deviations

  • The chips use the chrome face at the style's size and weight, not the document's own face. Loading the document faces into the chrome would risk a flash of unstyled text (the "never FOUT" rule).
  • No scrim behind the sheet. The page above stays readable, so you can see what you're formatting.
  • "Saving…" is still not shown. The editor still reports no saving state. This slice was chrome only.
  • Arabic and Russian. The chrome stays English (Docs ships en), and the sheet is left-to-right. RTL is P6.

New strings (drafts, for copy review)

docs.editor.inspector.close "Close", docs.editor.toolbar.size.down "Smaller", docs.editor.toolbar.size.up "Larger", docs.editor.toolbar.group.more "More", docs.editor.quickbar.hide "Hide keyboard".

Review requested: Fable.

Hub CI passed at 218c148 on the first run: gate and native both green. TestPushIsFasterThanTheFetchPath did not flake this time. Ready for review.

Review by Claude Fable (claude-fable-5-2) of 218c148 — verdict: APPROVE AFTER FIXES. Read-only, nothing reproduced. The command path is the desktop inspector's (same table, one transaction each). The keep-selection meta changes no content (no Yjs update, no undo entry). Remote edits map through ySync. No hard-coded English. The sheet CSS holds at 704–1024 and 1280.

Fix before merge:

  1. Medium (a11y) phone.js:232, :244: from.detail on a button is always undefined, so a keyboard-opened sheet never takes focus, and Esc then does nothing. Use if (from); let the document Esc close an open sheet; focus the sheet's h2 (tabindex -1) on open; make the :233 comment match. Test: Enter on Aa → focus in the sheet → Esc closes → focus is back on Aa.
  2. Medium-High phone.js:328-330, editor-entry.js:637-657: tapping the document while the sheet is open raises the keyboard over the sheet and suppresses the capsule. Aa stays expanded and the kept decoration sits over the live selection. On editor focusin, close the sheet. Add a test.
  3. Medium editor-entry.js:646-647: Aa mid-composition inserts the kept widget before blurring (Gboard, ja/zh IME). Blur first; if view.composing, apply the meta after compositionend. Hand-check Android Chrome.

Can follow:

  1. Font/size comboboxes in the sheet: blur after a pick; force lists downward inside the sheet where anchor positioning is unsupported; add a browser step.
  2. phone.js:293-297: translate the bar only when the keyboard is up and vv.scale ≈ 1 (pinch-zoom).
  3. phone.js:290: scale the threshold by vv.scale; use documentElement.clientHeight, not innerHeight; decide the fallback under resizes-content; add landscape coverage.
  4. editor-entry.js:1144-1147: re-dispatch the kept meta after a resync remount; setInert (:595) should respect refocus().
  5. place() forces layout twice per event: cache it or use one rAF.
  6. Swipe-close: close on pointerup, not pointermove (iOS keyboard).
  7. Tests: node tests for size_*, refocus, chip aria-pressed; a remote update while the sheet is open; B at a caret → × → type → bold.

Nits: pressed state is colour only, and [docs-qtool] has no forced-colors rule. The hide rules win by source order (show.html:1831-1832), so add :where() or a comment.

Fixes for Fable's review of 218c148: tip 236e0c1, hub CI passed (gate, native)

One commit per item. Each has a test, and where the fault could be reproduced the test was seen to fail first. Two can't be reproduced (3 in Chromium, and 8 isn't visible), and they say so.

| Item | Commit | What changed | Proof | |---|---|---|---| | 1 | 5c72cd7 | The opener alone decides (if (from)). Opened from a keyboard, focus goes to the sheet's h2 (tabindex="-1"). Escape anywhere closes the sheet unless something nearer used the key (!e.defaultPrevented). Focus returns to Aa, and the comment now matches. | TestTheSheetFromAKeyboard (Enter on Aa → focus in the sheet → Escape → closed, focus on Aa). Before the fix, focus stayed on Aa and Escape did nothing. | | 2 | 0f21f7f | The editor's focusin closes an open sheet first. | TestATapInTheDocumentClosesTheSheet: the sheet closed, nothing kept drawn, the caret in, the capsule shown, Aa not expanded. It failed before. | | 3 | 7aeed92 | The editor blurs first, then draws the kept selection. If a composition outlasts the blur, the kept caret waits for compositionend plus 50 ms (ProseMirror's own read), or 500 ms at most. | TestAaMidCompositionWaitsForIt composes "かな" through CDP (Input.imeSetComposition), then opens the sheet from script mid-composition. The composition ends before the kept caret is drawn, and the words land once. A guard, not a reproduction: Chromium's ProseMirror holds a decoration's DOM until the composition ends, so the old order passes too. No Android device or emulator here, so no hand-check on Android Chrome. | | 4 | 69db3c1 | A pick blurs the picker's filter box wherever refocus() keeps the caret out. The chips row is data-rst-select-ceiling, so ui/select.js opens the font and size lists below it, inside the sheet. A ceiling that isn't drawn is skipped, so the desktop is unaffected. | TestPickersInTheSheet picks Caladea, then 18: each applies, its list is below its box and inside the sheet, and no text box keeps focus. It failed before (the filter kept focus). | | 5 | e2d6882 | The bar is translated only while the keyboard is up and |vv.scale − 1| ≤ 0.01. | TestAPinchZoomLeavesTheBarAlone zooms 2× and 300 px down, with and without the caret: the bar stays at 0. It failed before (300). | | 6 | d2584e3 | The keyboard test is vv.height × vv.scale < documentElement.clientHeight − 150. Under resizes-content: a layout viewport more than 150 px short of its tallest at this width, with the caret in, gets the strip under the bar. | TestWhenTheKeyboardIsUp: zoomed with the caret, no capsule; the layout viewport shrunk by 336 px, the strip; back to full height, none. The first two failed before. Landscape screenshots (844×390) are in p2-docs-r2/chromium/: the capsule 8 px above a 200 px keyboard, and the sheet at half the height, scrolling. | | 7 | 71bf938 | Before a resync remount with the sheet open, the selection is taken as Yjs relative positions, with the old absolute positions as a fallback. A style chip makes the paragraph anew, and the refused change takes those items away, so there the absolute positions stand in. The new view gets it back with the kept meta. setInert's focus-back doesn't refocus while the sheet is open, and formatSheet is now declared before setInert reads it. | TestAResyncKeepsTheSelectionDrawn refuses (413) the save of a size step and of a style chip made from the sheet. The selection is still drawn over "Second paragraph.", and both failed with the re-dispatch removed. The refused change itself is dropped by the resync, as any refused change is. | | 8 | 7f68982 | The capsule's height is read once, the first time it shows, and kept. The only read left per event is clientHeight, before any write, and the position is written only when it changes. | No test: this changes how often the browser lays out, not what it draws. The capsule's place is still held by the tests above. | | 9 | 72fa1ea | The swipe closes on pointerup only. | TestTheFormatSheetAndTheQuickBar: still open after the moves, closed after the lift. The first check failed before. | | 10 | 5615bcb | Tests only. | toolbar.test.mjs: the size steps (one size at a time, stopping at both ends of the ladder, a dry run that doesn't act), refocus() (fails if a click always refocuses), and a chip's aria-pressed and its command. The stand-in DOM now keeps listeners. TestARemoteEditWhileTheSheetIsOpen uses a new vector, remote-before.bin; the other vectors regenerate byte for byte. A collaborator's paragraph lands above the selection, the kept selection moves with its text, and Heading 2 then heads that text. TestBoldAtACaretFromTheSheet: B at a caret, then ×, then Z gives a bold Z. These all passed on the branch: they hold behaviour that was right. | | Nits | 236e0c1 | Forced colours: the capsule's pressed and expanded buttons get the outline the toolbar's tools already had, which covers the chips too. A comment on the hide rules says they win by weight and order, and why :where() would undo that. | TestTheQuickBarInForcedColours emulates forced-colors: active and presses B: its outline is solid. Before the fix it was none. |

Mobile Safari (iOS 27.0 simulator, real taps through XCUITest)

I booted the shut-down "Kass UI iOS" myself and shut down only that device afterwards. The other session's iPhone 18 Pro was left alone. The scratch apps were uninstalled.

  • 1: focus Aa and activate it as a keyboard does (a click with no detail), then Escape. Focus is on the sheet's title, and the sheet then closes with focus back on Aa. This was driven from script: XCUITest has no way to tab to a web button.
  • 2: a real tap in a word with the keyboard up, a double-tap, then the capsule's Aa: the sheet opens and the keyboard goes. A real tap in the document then closes the sheet; the keyboard comes up with the capsule, nothing kept is drawn, and Aa reads aria-expanded="false".
  • 9: a real drag on the sheet's title, 200 px down and held 1.5 s. The page recorded the sheet still open while held past 60 px, and closed after the lift.

Evidence is in polish-audit/docs-phone-web/build/p2-docs-r2/: mobile-safari/ (screenshots, report.jsonl, the XCUITest lines and source, the probe) and chromium/ (landscape).

Runs

Under the lock, one run each:

  • every touched browser test: the sheet, format, phone screen, resync, carry, I2 engines (Chromium and WebKit), zoom, rhythm, font status, rename and save-failure tests;
  • the full internal/docs unit suite;
  • go vet -tags browser;
  • the toolbar, toolbar-roving and menu node tests.

All green. The bundle is fresh (editor.470aeecd64ebb8df.js).

Delta review by Claude Fable (claude-fable-5-2) of 218c148..236e0c1 — APPROVE. All ten fixes and the nits are right. No close loop (2); keep() always runs and is idempotent (3); no flap (6); desktop, no-script and FOUT are unaffected.

Follow-ups (next branch):

  • A editor-entry.js:99-100: after a resync, the absolute fallback can point at the wrong text if other changes arrived in the rebuild (live updates are dropped while diverged; the refused batch is merged with earlier typing). Record the kept text and the anchor block's text; use the fallback only if they match, else the nearest matching block, else close the sheet. Test with remote-before.bin landed server-side before the 413.
  • B menu.mjs:164: view.focus() after menu commands ignores refocus() (••• → Undo closes the sheet and flashes the keyboard).
  • C phone.js:300-305: key tallestAt on clientWidth; comment the edges.
  • D phone_sheet_browser_test.go:179-186: assert the tap puts the caret where tapped; hand-check on iOS.
  • E nits: TextSelection.between/Selection.near; Esc in a native dialog also closes the sheet; check VoiceOver activation for e.detail === 0.