oficina / mapa Public

Smooth nav: no screen scrolls by a stray pixel

[mapa-sr] sat at its static place, so the editor's two live regions,
appended to <body>, hung 1px below the page and every page with the
editor scrolled by that pixel. It is now pinned to its containing
block's corner as well as clipped. Build note 59;
TestNoScreenScrollsByAStrayPixel checks ten screens at 390, 800 and
1280px, scripts off and on.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev 6f1f1381dd3beed3da8565ba412fbdb570f02379 parent fa41bef
3 files changed, +56 −2
  • docs/superpowers/specs/2026-11-14-mapa-level-up.md +1 −0
  • internal/mapa/static/frame.css +5 −0
  • internal/mapatest/navigation_browser_test.go +50 −2
diff --git a/docs/superpowers/specs/2026-11-14-mapa-level-up.md b/docs/superpowers/specs/2026-11-14-mapa-level-up.md
index 7b56046..1a842f9 100644
--- a/docs/superpowers/specs/2026-11-14-mapa-level-up.md
+++ b/docs/superpowers/specs/2026-11-14-mapa-level-up.md
@@ -1113,6 +1113,7 @@ Phase 1's choices where this spec was silent, or where the build chose different
**Smooth navigation** (Paul, 14 November: "clicking links should feel very smooth and solid"; §6.9):
58. **A block link lands without a jump, and without script.** A block chip's address is `/p/{id}#b-…`, and the browser's own fragment scroll used to put the block at the window's top edge, under the 56px sticky bar, with nothing to say why the page had moved. Now `html` has `scroll-padding-block-start` of the bar plus 16px, so any in-page target (`#main`, a heading) clears the bar, and a block (`[id^="b-"]` in the page's body, so pages, days, scratch pages and History's versions alike) has a `scroll-margin-block-start` that puts its top 40% of the way down the view the bar leaves: 353px of a 1280×800 window, 389px of a 390×844 phone. 40% because a block starting there or above in the first screen (a page's title and its first few blocks, the usual target on Mapa's short pages) is not scrolled to at all, while a deep block still arrives in the upper part of the view, with what leads to it above and room for what follows; a page too short to scroll never moves. CSS cannot say "only if it is not already in view": a fragment always aligns the start, so a block starting between 40% and the first screen's foot is still moved up to 40%, by less than the screen. The block is tinted with the accent's soft fill, which holds and then fades over 1.8s; under `prefers-reduced-motion` it holds 1.5s and goes, without a fade. The tint is a box shadow (inset for the fill, spread 4px for its rim), so nothing is laid out again and a code block's own background stays under it. The editor draws the block anew as it mounts (here the server's `<ul>` is replaced before first paint); in Chromium and WebKit the new element does not match `:target` at `DOMContentLoaded`, but both match it again by the end of the load, and the tint's animation starts then, once (measured: one `mapa-arrive` animation, current time equal to the time since load). The gate (`TestABlockLinkLandsWithoutAJump`, `make browser`) clicks a chip to an early and a deep block at 1280×800 and 390×844, scripts off and on: the early one scrolls nothing, the deep one's top is within 2px of the 40% line, and both match `:target` and are tinted. Without the change it lands every block 0px under the bar's edge, which the gate catches.
+59. **No screen scrolls by a stray pixel.** `[mapa-sr]` (the visually hidden class) was absolutely positioned at its static place, so the editor's two live regions (the `[[` and `/` lists'), appended to `<body>`, hung 1px below the page's end and every page with the editor scrolled by that pixel (`scrollHeight` was the window's plus one). It is now pinned to its containing block's corner (`inset-block-start: 0; inset-inline-start: 0`), as well as clipped. The gate (`TestNoScreenScrollsByAStrayPixel`) loads a day, an unwritten day, a short page, its History, Scratch, New scratch page, Search with and without a query, Settings and All pages at 390, 800 and 1280px wide and 800px tall, scripts off and on (after the mount), and requires `scrollHeight` to be no more than the window or the body's own flow, whichever is taller: a short page cannot scroll at all.
## 14. Findings and what changed
diff --git a/internal/mapa/static/frame.css b/internal/mapa/static/frame.css
index fd1f70a..c106f6a 100644
--- a/internal/mapa/static/frame.css
+++ b/internal/mapa/static/frame.css
@@ -306,8 +306,13 @@ h1[mapa-title] {
@media (max-width: 799.98px) {
h1[mapa-title] { font-size: 1.875rem; }
}
+/* Visually hidden. Pinned to its containing block's corner: at its
+ static place a live region appended to <body> sat 1px below the
+ page's end, and every page scrolled by that pixel. */
[mapa-sr] {
position: absolute;
+ inset-block-start: 0;
+ inset-inline-start: 0;
clip-path: inset(50%);
inline-size: 1px;
block-size: 1px;
diff --git a/internal/mapatest/navigation_browser_test.go b/internal/mapatest/navigation_browser_test.go
index 3c50d46..69b0248 100644
--- a/internal/mapatest/navigation_browser_test.go
+++ b/internal/mapatest/navigation_browser_test.go
@@ -15,8 +15,8 @@ import (
"amadan.net/oficina/mapa/internal/mapa"
)
-// Navigation that feels solid (build note 58): a block link lands
-// without a jump.
+// Navigation that feels solid (build notes 58 and 59): a block link
+// lands without a jump, and no screen scrolls by a stray pixel.
// longBody is forty paragraphs, ^early in the second and ^deep in the
// thirtieth.
@@ -107,3 +107,51 @@ func land(t *testing.T, rig *harness.Rig, from, block string,
})
return seen
}
+
+// overflow is the document's scroll height against what its content
+// needs: the window, or the body's own flow if that is taller. With
+// scripts on (live is true) and an editor's island on the page, it
+// waits for the mount, which adds the [[ and / lists' live regions.
+const overflow = `(function (live) {
+ if (live && document.getElementById("mapa-editor") &&
+ !document.querySelector(".ProseMirror")) return "";
+ var body = document.body.getBoundingClientRect();
+ var needs = Math.max(innerHeight, Math.ceil(body.bottom + scrollY));
+ var height = document.documentElement.scrollHeight;
+ return height <= needs ? "ok" : height + " > " + needs;
+})`
+
+// No screen is taller than its content: a visually hidden element (a
+// live region appended to <body>) once hung 1px below every page, so
+// each one scrolled by that pixel. A short page cannot scroll at all.
+func TestNoScreenScrollsByAStrayPixel(t *testing.T) {
+ rig, store := browserRig(t, 0)
+ page, err := store.CreateTeamPage(context.Background(), Bo, "Short",
+ "One line.")
+ if err != nil {
+ t.Fatal(err)
+ }
+ path := mapa.PagePath(page)
+ screens := []string{"/", "/d/2026-11-10", path, path + "/history",
+ "/scratch", "/scratch/new", "/search", "/search?q=line",
+ "/settings", "/pages"}
+ for _, live := range []bool{false, true} {
+ for _, width := range []int64{390, 800, 1280} {
+ for _, screen := range screens {
+ drive(t, rig, scripts(live), chromedp.EmulateViewport(width,
+ 800), chromedp.Navigate(rig.Origin+screen),
+ chromedp.WaitReady("body"))
+ var got string
+ eventually(t, "the page settled", func() bool {
+ got = read(t, rig, chromedp.Evaluate[string](
+ fmt.Sprintf("%s(%v)", overflow, live)))
+ return got != ""
+ })
+ if got != "ok" {
+ t.Errorf("%s at %dpx, scripts %v: %s", screen, width,
+ live, got)
+ }
+ }
+ }
+ }
+}