oficina / fichas Public

The bar's Search is the lens alone, with ⌘K in its tooltip

Paul, 2026-11-18: the header's Search can be a lens icon with ⌘K. It
stays in the bar (a phone has no sidebar, and in rail mode the bar is
where people look) and is now drawn by estilo's new Action.IconOnly:
no visible word, "Search" its accessible name, aria-keyshortcuts
"Meta+K Control+K", and "Search ⌘K" as its tooltip on hover and
keyboard focus (rastrillo's rst-tip). It still goes to the list's Find
box, and links to #find with scripts off. On a touch screen it takes a
tap anywhere in 44px. Below 800px the Menu sheet's row keeps the word
and the key, as before. History and New are unchanged.

⌘K now does what the tooltip says on a page with no Find box (a card,
History): it goes where the lens goes, never from inside a field.

Re-pin estilo 39792ae -> d004805 (static/ re-copied with
scripts/writeestilo): the icon-only action, and the commits between,
the stacked title fitted in Chromium (4d5b935), Mapa's and Equipo's
marks (f724edb) and desk (c1773e0), none of which Fichas uses beyond
chrome.css and chrome.js.

Copy: Luna approved the name and the tooltip as drafted
(copy-review/search-icon). Gates: browser_search_icon_test.go checks no
visible text, the name, the shortcut, the tooltip on hover and on
keyboard focus and whole on screen, the action with scripts on and off,
⌘K from a card, axe on the list and a card at 1440, 1000 and 800, no
shift in the bar (scripts off against on, and no layout-shift entry in
the bar), and the 44px tap. Each was seen failing with IconOnly off and
with estilo's hit area removed. make ci and make browser green.

Reviewed by Claude Fable across estilo, Mapa and Fichas: no High; the
two Mediums (⌘K advertised where it did nothing; a focus check that
could skip) fixed, and a delta review found no High or Medium.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Squashed from fix/search-icon into main.
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 6a57585519ef368cceadae32f12b2ebc5890d24d parent b3d1397
9 files changed, +379 −21
  • copy-review/search-icon/result.json +26 −0
  • copy-review/search-icon/strings.json +18 −0
  • go.mod +1 −1
  • go.sum +2 −2
  • internal/fichas/frame.go +5 −2
  • internal/fichas/static/chrome.css +29 −3
  • internal/fichas/static/chrome.js +20 −12
  • internal/fichas/static/grid.js +6 −1
  • internal/fichastest/browser_search_icon_test.go +272 −0

CI passed — run details

CI log
=== vet ===
go vet ./...
go: downloading amadan.net/oficina/estilo.git v0.0.0-20261118055615-d004805f40f2
go vet -tags browser ./internal/fichastest/
=== fmt ===
=== test ===
go test ./...
?   	amadan.net/oficina/fichas/cmd/fichas	[no test files]
ok  	amadan.net/oficina/fichas/internal/fichas	2.360s
?   	amadan.net/oficina/fichas/internal/fichas/icons	[no test files]
ok  	amadan.net/oficina/fichas/internal/fichas/locale	0.010s
ok  	amadan.net/oficina/fichas/internal/fichas/seal	(cached)
ok  	amadan.net/oficina/fichas/internal/fichastest	1.880s
?   	amadan.net/oficina/fichas/scripts/mockups	[no test files]
?   	amadan.net/oficina/fichas/scripts/preview	[no test files]
?   	amadan.net/oficina/fichas/scripts/writeestilo	[no test files]
=== migration-check ===
go tool rastrillo migration check
rastrillo migration check: models and migrations agree
diff --git a/copy-review/search-icon/result.json b/copy-review/search-icon/result.json
new file mode 100644
index 0000000..e75d59a
--- /dev/null
+++ b/copy-review/search-icon/result.json
@@ -0,0 +1,26 @@
+{
+ "action": "approve",
+ "guidance": null,
+ "note": "Reviewed 2026-11-18 by Luna (gpt-5.6-luna through Codex, ephemeral), the copy-review gate for Oficina copy since Paul's delegation of 2026-11-17, briefed with Paul's house rules from CARLOS platform's LUNA-COPY-BRIEF-stateless-replicas-4.md. Luna approved every string as drafted, with no edits and no flags.",
+ "strings": [
+ {
+ "id": "bar.search.name",
+ "text": "Search",
+ "original": "Search",
+ "edited": false,
+ "rerolled": false,
+ "rerolls": [],
+ "done": true
+ },
+ {
+ "id": "bar.search.tooltip",
+ "text": "Search ⌘K",
+ "original": "Search ⌘K",
+ "edited": false,
+ "rerolled": false,
+ "rerolls": [],
+ "done": true
+ }
+ ],
+ "flags": "none"
+}
diff --git a/copy-review/search-icon/strings.json b/copy-review/search-icon/strings.json
new file mode 100644
index 0000000..408f51b
--- /dev/null
+++ b/copy-review/search-icon/strings.json
@@ -0,0 +1,18 @@
+[
+ {
+ "id": "bar.search.name",
+ "section": "The bar",
+ "label": "Search's accessible name",
+ "text": "Search",
+ "context": "The header's Search is now the lens icon alone; this is its aria-label. The shortcut is aria-keyshortcuts (Meta+K Control+K), not part of the name.",
+ "notes": "Unchanged wording; it was the visible label."
+ },
+ {
+ "id": "bar.search.tooltip",
+ "section": "The bar",
+ "label": "Search's tooltip",
+ "text": "Search ⌘K",
+ "context": "Shown on hover and keyboard focus over the lens: the name, a space, and the shortcut as the app writes it elsewhere.",
+ "notes": "New."
+ }
+]
diff --git a/go.mod b/go.mod
index 0d6162e..ef24d2c 100644
--- a/go.mod
+++ b/go.mod
@@ -5,7 +5,7 @@ go 1.26.0
toolchain go1.26.11
require (
- amadan.net/oficina/estilo.git v0.0.0-20261111234914-39792ae278b0
+ amadan.net/oficina/estilo.git v0.0.0-20261118055615-d004805f40f2
amadan.net/oficina/suite v0.0.0-20261102002704-91affa14eae4
amadan.net/rastrillo/rastrillo v0.35.1-0.20261116213651-96812beacacc
github.com/chromedp/cdproto v0.158.6
diff --git a/go.sum b/go.sum
index d00f93f..d4d2503 100644
--- a/go.sum
+++ b/go.sum
@@ -1,5 +1,5 @@
-amadan.net/oficina/estilo.git v0.0.0-20261111234914-39792ae278b0 h1:6xlOgfIuccF6xuxErZRz5Vzm+V1Y5eE/vW2ppwzHzrY=
-amadan.net/oficina/estilo.git v0.0.0-20261111234914-39792ae278b0/go.mod h1:2UFIFrbTrhew8EFM0C94WmTo2OASM2pHEgT4jzeE/s8=
+amadan.net/oficina/estilo.git v0.0.0-20261118055615-d004805f40f2 h1:E2+IhBdGcjhX3IX8UgQj5t6Bu+4zkGG0J+W1CIeoTAo=
+amadan.net/oficina/estilo.git v0.0.0-20261118055615-d004805f40f2/go.mod h1:2UFIFrbTrhew8EFM0C94WmTo2OASM2pHEgT4jzeE/s8=
amadan.net/oficina/suite v0.0.0-20261102002704-91affa14eae4 h1:BP+KHZTSgL7HDCz9IL/gxKXmbmXQpclUlJIyQEY/N2E=
amadan.net/oficina/suite v0.0.0-20261102002704-91affa14eae4/go.mod h1:Xgw0N+DBiDzkhQHm/nIhgumfaiMElDg/KIFD1OxTm5w=
amadan.net/rastrillo/fiesta v1.3.0 h1:7SsHw4aeWPLStR3RHFEEtX4CwqKu+Ig3PgNX8FvD8WM=
diff --git a/internal/fichas/frame.go b/internal/fichas/frame.go
index 9c7bbba..ddfbd4e 100644
--- a/internal/fichas/frame.go
+++ b/internal/fichas/frame.go
@@ -201,13 +201,16 @@ func orText(s, def string) string {
return s
}
-// barActions: Search, History on a card, and the primary New.
+// barActions: Search, History on a card, and the primary New. Search is
+// the lens alone in the bar (Paul, 2026-11-18): "Search" is its name,
+// "Search ⌘K" its tooltip, and the Menu sheet's row keeps the word.
func barActions(f frameFacts) []chrome.Action {
search := "/"
if f.TypeKey != "" {
search = typeHref(f.TypeKey) + "#find"
}
- actions := []chrome.Action{{Item: menu.Item{Href: search, Label: "Search", Key: "⌘K"}, Icon: icons.Icon("search")}}
+ actions := []chrome.Action{{Item: menu.Item{Href: search, Label: "Search", Key: "⌘K"}, Icon: icons.Icon("search"),
+ IconOnly: true, KeyShortcuts: "Meta+K Control+K"}}
if f.CardID != 0 {
actions = append(actions, chrome.Action{Item: menu.Item{Href: "/cards/" + strconv.FormatInt(f.CardID, 10) + "/history", Label: "History"}, Icon: icons.Icon("history")})
}
diff --git a/internal/fichas/static/chrome.css b/internal/fichas/static/chrome.css
index 548c881..92d0fd4 100644
--- a/internal/fichas/static/chrome.css
+++ b/internal/fichas/static/chrome.css
@@ -302,15 +302,16 @@
/* ── Bar stack (Docs' I2 editor header, spec 2026-11-11) ────────────────
Everything below is opt-in. Each rule is keyed on a hook only a bar
- with a slot, a WideOnly action or the Appearance form renders, so a bar
- with neither Menubar nor Lead looks exactly as it did
+ with a slot, a WideOnly or IconOnly action or the Appearance form
+ renders, so a bar with none of them looks exactly as it did
(TestEverythingAfterTheMarkerIsOptIn holds this, and that main's rules
above are unchanged).
The hooks: [estilo-bar~="stacked"] (Bar.Menubar), [estilo-bar-stack]
and [estilo-bar-menubar] inside it, [estilo-bar-lead] (Bar.Lead),
[estilo-bar-control] (each action in a bar with a slot),
- [estilo-bar-wide] (Action.WideOnly) and [estilo-appearance].
+ [estilo-bar-wide] (Action.WideOnly), [estilo-bar-icon]
+ (Action.IconOnly) and [estilo-appearance].
Breakpoints: 800px is rastrillo's shell breakpoint, the rule above
this section and every app's, so it stays in px: restated in rem it
@@ -591,6 +592,19 @@
background-position: right center;
}
+ /* An icon-only action (Action.IconOnly: Search in Mapa and Fichas):
+ a square as tall as the set's controls, the glyph centred. Its
+ label is its accessible name and, with its shortcut, the tooltip
+ the template asks rastrillo's rst-tip for, which hangs from this
+ box, so the box is positioned. (0,2,0) outweighs the set's pill. */
+ [estilo-bar-actions] [estilo-bar-icon] {
+ position: relative;
+ justify-content: center;
+ inline-size: 28px;
+ min-inline-size: 28px;
+ padding-inline: 0;
+ }
+
/* Coarse pointers: the header's controls rise to 32px, and the menubar
titles keep their 24px look in the 20px row but take 32px of hit
area, 4px over each edge, drawn by nothing and taking no room. Where
@@ -604,6 +618,18 @@
[estilo-bar~="stacked"] [estilo-menubar-title] { position: relative; }
[estilo-bar~="stacked"] [estilo-menubar-title]::before { content: ""; position: absolute; inset-inline: 0; inset-block: -4px; }
[estilo-bar~="stacked"] [estilo-bar-title] { z-index: 1; }
+ /* The icon-only action is drawn 32px like the rest, and takes 44px
+ to a tap: 6px over each edge, drawn by nothing, inside the 56px
+ header and short of the 8px to its neighbours. ::before, since
+ ::after is the tooltip. */
+ [estilo-bar-actions] [estilo-bar-icon] { inline-size: 32px; min-inline-size: 32px; }
+ [estilo-bar-actions] [estilo-bar-icon]::before { content: ""; position: absolute; inset: -6px; }
+ }
+ /* Where nothing hovers (a tablet), a tap leaves :hover on the control,
+ and the tooltip would stay up until the next tap elsewhere. There it
+ shows for keyboard focus only. */
+ @media (hover: none) {
+ [estilo-bar-actions] [estilo-bar-icon]:not(:focus-visible)::after { display: none; }
}
}
@media (min-width: 64rem) {
diff --git a/internal/fichas/static/chrome.js b/internal/fichas/static/chrome.js
index 9b39c8c..f3891fd 100644
--- a/internal/fichas/static/chrome.js
+++ b/internal/fichas/static/chrome.js
@@ -90,22 +90,30 @@
// The stacked bar's title field is as wide as its title (Paul: "It
// should grow according to the title, not start out full-width"). The
- // field measures itself: at zero width its scroll width is its own text
- // as it draws it with both its paddings (Chromium and WebKit alike), so
- // only the borders go on top, and 2px for the caret at the end of the
- // text. field-sizing: content, a canvas and a mirror span in the same
- // font all came out short in WebKit; this did not. CSS caps the width
- // at the room the field has (max-inline-size, which from 800px allows
- // for the field's pulled-back start margin), so a longer title still
- // scrolls inside the field. Nothing after the title on its row moves
- // when it changes: the stack takes the room.
+ // field measures itself, at zero width, where its scroll width is its
+ // own text as it draws it. The engines measure that in different boxes:
+ // WebKit's scroll and client widths are the padding box, so its scroll
+ // width holds both paddings; Chromium's are the content box (its inner
+ // editor), so its scroll width is the text alone and its client width
+ // 0. Measured on Chromium 158 and WebKit 27.2, "Brightwater Labs":
+ // scroll width 127 and 141, client width 0 and 13. Adding only the
+ // borders, as this once did, cut the last letter off in Chromium (the
+ // field 12.8px short: both paddings). So whatever of the field lies
+ // outside the box the scroll width is measured in goes on top,
+ // offsetWidth less clientWidth: the borders in WebKit, the borders and
+ // paddings in Chromium. Then 2px for the caret at the end of the text.
+ // field-sizing: content, a canvas and a mirror span in the same font
+ // all came out short in WebKit; this did not. CSS caps the width at the
+ // room the field has (max-inline-size, which from 800px allows for the
+ // field's pulled-back start margin), so a longer title still scrolls
+ // inside the field. Nothing after the title on its row moves when it
+ // changes: the stack takes the room. make test-browser holds it in
+ // both engines (title_browser_test.go).
const FIT = '[estilo-bar-title-input][size]'
const CARET = 2
const fit = (input) => {
- const cs = getComputedStyle(input)
- const px = (v) => parseFloat(v) || 0
input.style.inlineSize = '0px'
- const w = input.scrollWidth + px(cs.borderInlineStartWidth) + px(cs.borderInlineEndWidth)
+ const w = input.scrollWidth + input.offsetWidth - input.clientWidth
input.style.inlineSize = Math.ceil(w + CARET) + 'px'
}
const fitAll = () => { Array.prototype.forEach.call(document.querySelectorAll(FIT), fit) }
diff --git a/internal/fichas/static/grid.js b/internal/fichas/static/grid.js
index 809714b..6688927 100644
--- a/internal/fichas/static/grid.js
+++ b/internal/fichas/static/grid.js
@@ -623,7 +623,12 @@
}
if (mod && (e.key === "k" || e.key === "K")) {
var q = document.querySelector('[data-live-search] input[name="q"]');
- if (q) { e.preventDefault(); q.focus(); q.select(); }
+ if (q) { e.preventDefault(); q.focus(); q.select(); return; }
+ // No Find box here (a card, History): go where the bar's Search
+ // goes, the list's Find box, so ⌘K does what its tooltip says.
+ // Never from inside a field, where it would leave typing unsaved.
+ var lens = document.querySelector("[estilo-bar] a[estilo-bar-icon]");
+ if (lens && !inField(t) && lens.pathname !== location.pathname) { e.preventDefault(); location.assign(lens.href); }
return;
}
if (mod && e.key === "\\") {
diff --git a/internal/fichastest/browser_search_icon_test.go b/internal/fichastest/browser_search_icon_test.go
new file mode 100644
index 0000000..da0ec44
--- /dev/null
+++ b/internal/fichastest/browser_search_icon_test.go
@@ -0,0 +1,272 @@
+//go:build browser
+
+package fichastest
+
+import (
+ "context"
+ "encoding/json"
+ "fmt"
+ "testing"
+ "time"
+
+ "amadan.net/rastrillo/rastrillo/harness"
+ "github.com/chromedp/cdproto/cdp"
+ "github.com/chromedp/cdproto/emulation"
+ "github.com/chromedp/cdproto/input"
+ "github.com/chromedp/cdproto/page"
+ "github.com/chromedp/chromedp"
+ "github.com/chromedp/chromedp/kb"
+)
+
+// The bar's Search is the lens alone (Paul, 2026-11-18): no visible word,
+// "Search" its accessible name, its shortcut aria-keyshortcuts, "Search
+// ⌘K" its tooltip on hover and on focus, whole on screen. It still goes
+// to the list's Find box; it moves nothing as the page loads; axe finds
+// nothing serious; and on a touch screen a tap lands on it anywhere in
+// 44px.
+
+// barSearch is the bar's Search, on screen from 800px.
+const barSearch = `[estilo-bar-actions] a[href$="#find"]`
+
+// searchFacts is what the bar's Search shows and says. Misses lists the
+// middles of the tooltip's edges a pointer could not reach (it takes
+// pointer events for the moment it is asked), so a box laid out but cut
+// off fails.
+const searchFacts = `(function () {
+ var a = document.querySelector(%q), box = a.getBoundingClientRect();
+ var tip = getComputedStyle(a, "::after");
+ var probe = document.createElement("style");
+ probe.textContent = "[estilo-bar-icon]::after { pointer-events: auto !important; transition: none !important; }";
+ document.head.appendChild(probe);
+ // The tooltip's border box: rst-tip hangs it 6px under the control,
+ // its end on the control's end. The middle of each edge, 2px in (the
+ // corners are rounded), must be the tooltip's.
+ var pad = function (side) { return parseFloat(tip["padding" + side]); };
+ var content = tip.boxSizing !== "border-box";
+ var width = parseFloat(tip.width) +
+ (content ? pad("Left") + pad("Right") : 0);
+ var height = parseFloat(tip.height) +
+ (content ? pad("Top") + pad("Bottom") : 0);
+ var right = box.right, top = box.bottom + 6, left = right - width;
+ var misses = isFinite(width) && isFinite(height) ? [] :
+ ["no tooltip box"];
+ if (!misses.length) [[left + width / 2, top + 2],
+ [left + width / 2, top + height - 2], [left + 2, top + height / 2],
+ [right - 2, top + height / 2]
+ ].forEach(function (p) {
+ if (!a.contains(document.elementFromPoint(p[0], p[1]))) {
+ misses.push(Math.round(p[0]) + "," + Math.round(p[1]));
+ }
+ });
+ probe.remove();
+ return JSON.stringify({Text: a.innerText.trim(),
+ Name: a.getAttribute("aria-label"),
+ Keys: a.getAttribute("aria-keyshortcuts"),
+ Tip: tip.content, Shown: tip.opacity, Misses: misses.join(" "),
+ Width: box.width, Height: box.height});
+})()`
+
+type searchShows struct {
+ Text, Name, Keys, Tip, Shown, Misses string
+ Width, Height float64
+}
+
+func showsOf(t *testing.T, rig *harness.Rig) searchShows {
+ t.Helper()
+ var raw string
+ rig.Run(harness.Into(&raw, chromedp.Evaluate[string](fmt.Sprintf(searchFacts, barSearch))))
+ var got searchShows
+ if err := json.Unmarshal([]byte(raw), &got); err != nil {
+ t.Fatal(err)
+ }
+ return got
+}
+
+// hoverOver moves the mouse to the middle of selector's element.
+func hoverOver(selector string) chromedp.Action[chromedp.Void] {
+ return chromedp.Func(func(ctx context.Context, target *chromedp.Target) error {
+ box, err := chromedp.Run(ctx, chromedp.Dimensions(selector))
+ if err != nil {
+ return err
+ }
+ q := box.Content
+ return chromedp.Do(ctx, chromedp.MouseEvent(input.DispatchMouseEventTypeMouseMoved, (q[0]+q[4])/2, (q[1]+q[5])/2),
+ chromedp.Sleep(200*time.Millisecond))
+ })
+}
+
+func scriptsOn(on bool) chromedp.Action[chromedp.Void] {
+ return send(emulation.SetScriptExecutionDisabled, emulation.SetScriptExecutionDisabledParams{Value: !on})
+}
+
+func TestTheBarsSearchIsTheLensAlone(t *testing.T) {
+ s := seedCards(t, 3)
+ for _, path := range []string{"/t/t_customer", cardPath(s.ids[0])} {
+ for _, width := range []int64{1440, 1000, 800} {
+ s.rig.Run(
+ send(emulation.SetDeviceMetricsOverride, emulation.SetDeviceMetricsOverrideParams{Width: width, Height: 900, DeviceScaleFactor: 1}),
+ chromedp.Navigate(s.rig.Origin+path),
+ chromedp.WaitVisible(barSearch),
+ )
+ got := showsOf(t, s.rig)
+ if got.Text != "" || got.Name != "Search" || got.Keys != "Meta+K Control+K" || got.Tip != `"Search ⌘K"` {
+ t.Errorf("%s at %dpx: the bar's Search is %+v", path, width, got)
+ }
+ if got.Width != got.Height || got.Width < 24 {
+ t.Errorf("%s at %dpx: the lens is %vx%v, not a square of at least 24px", path, width, got.Width, got.Height)
+ }
+ if got.Shown != "0" {
+ t.Errorf("%s at %dpx: the tooltip shows at rest (opacity %s)", path, width, got.Shown)
+ }
+ s.rig.Run(hoverOver(barSearch))
+ if got := showsOf(t, s.rig); got.Shown != "1" || got.Misses != "" {
+ t.Errorf("%s at %dpx: on hover the tooltip is at opacity %s, cut off at %q", path, width, got.Shown, got.Misses)
+ }
+ // Keyboard focus, reached by keys (Shift+Tab off the lens and
+ // Tab back), so :focus-visible holds as it does for a person.
+ var focused bool
+ s.rig.Run(hoverOver("[fichas-main]"), chromedp.Focus(barSearch),
+ chromedp.KeyEvent(kb.Tab, chromedp.KeyModifiers(chromedp.ModifierShift)), chromedp.KeyEvent(kb.Tab),
+ chromedp.Sleep(200*time.Millisecond),
+ harness.Into(&focused, chromedp.Evaluate[bool](`document.querySelector('`+barSearch+`').matches(":focus-visible")`)))
+ if !focused {
+ t.Fatalf("%s at %dpx: the lens did not take keyboard focus", path, width)
+ }
+ if got := showsOf(t, s.rig); got.Shown != "1" {
+ t.Errorf("%s at %dpx: on focus the tooltip is at opacity %s", path, width, got.Shown)
+ }
+ axeCheck(t, s.rig, path, width, "")
+ }
+ }
+
+ // The same action as before: the list's Find box, with scripts and
+ // without (a link to #find).
+ var active bool
+ var hash string
+ s.rig.Run(
+ wide(), chromedp.Navigate(s.rig.Origin+"/t/t_customer"), chromedp.WaitVisible(barSearch),
+ chromedp.Click(barSearch), chromedp.Sleep(200*time.Millisecond),
+ harness.Into(&active, chromedp.Evaluate[bool](`document.activeElement === document.querySelector('[data-live-search] input[name="q"]')`)),
+ scriptsOn(false), chromedp.Navigate(s.rig.Origin+"/t/t_customer"), chromedp.WaitReady(barSearch),
+ chromedp.Click(barSearch), chromedp.Sleep(300*time.Millisecond),
+ harness.Into(&hash, chromedp.Evaluate[string](`location.pathname + location.hash`)),
+ scriptsOn(true),
+ )
+ // ⌘K on a card, where there is no Find box, goes where the lens
+ // goes: the list's Find box.
+ var after string
+ s.rig.Run(
+ chromedp.Navigate(s.rig.Origin+cardPath(s.ids[0])), chromedp.WaitVisible(barSearch),
+ chromedp.KeyEvent("k", chromedp.KeyModifiers(chromedp.ModifierMeta)),
+ chromedp.WaitVisible(`[data-live-search] input[name="q"]`),
+ harness.Into(&after, chromedp.Evaluate[string](`location.pathname + location.hash`)),
+ )
+ if after != "/t/t_customer#find" {
+ t.Errorf("⌘K on a card went to %s", after)
+ }
+ if !active {
+ t.Error("the lens did not focus the Find box")
+ }
+ if hash != "/t/t_customer#find" {
+ t.Errorf("with scripts off the lens went to %s", hash)
+ }
+
+ // Below 800px the actions are the Menu sheet's rows, which keep the
+ // word and the shortcut.
+ var row string
+ s.rig.Run(
+ send(emulation.SetDeviceMetricsOverride, emulation.SetDeviceMetricsOverrideParams{Width: 390, Height: 844, DeviceScaleFactor: 1}),
+ chromedp.Navigate(s.rig.Origin+"/t/t_customer"), chromedp.WaitVisible("[estilo-bar-more] > summary"),
+ harness.Into(&row, chromedp.Evaluate[string](`document.querySelector('[estilo-menu="sheet"] a[href$="#find"]').textContent`)),
+ )
+ if row != "Search⌘K" {
+ t.Errorf("the Menu sheet's Search row reads %q", row)
+ }
+}
+
+// shiftRecorder keeps every layout shift from the start of the load
+// that moved something in the bar (this gate's subject; the page body
+// is not), naming what moved.
+const shiftRecorder = `(function () {
+ window.__shifts = [];
+ try {
+ new PerformanceObserver(function (list) {
+ list.getEntries().forEach(function (entry) {
+ (entry.sources || []).forEach(function (source) {
+ var el = source.node && (source.node.nodeType === 1 ? source.node : source.node.parentElement);
+ if (el && el.closest("[estilo-bar]")) __shifts.push(el.outerHTML.slice(0, 80) + " " + entry.value);
+ });
+ });
+ }).observe({ type: "layout-shift", buffered: true });
+ } catch (error) {}
+})()`
+
+// No shift (Mapa's L5, for the bar): the lens and every control beside
+// it are where the server drew them (scripts off) once the page's
+// scripts have run, and no layout shift moves anything in the bar from
+// the start of the load, on the list and on a card.
+func TestTheBarsSearchMovesNothing(t *testing.T) {
+ s := seedCards(t, 3)
+ const bar = `JSON.stringify(Array.prototype.map.call(
+ document.querySelectorAll("[estilo-bar-end] > *, [estilo-bar-actions] a, [estilo-bar-actions] button"),
+ function (el) { var b = el.getBoundingClientRect();
+ return [el.nodeName, b.left, b.top, b.width, b.height].join(" "); }))`
+ s.rig.Run(chromedp.Func(func(ctx context.Context, target *chromedp.Target) error {
+ _, err := cdp.Call(ctx, target, page.AddScriptToEvaluateOnNewDocument,
+ page.AddScriptToEvaluateOnNewDocumentParams{Source: shiftRecorder})
+ return err
+ }))
+ for _, path := range []string{"/t/t_customer", cardPath(s.ids[0])} {
+ for _, width := range []int64{1440, 1000} {
+ load := func(live bool) string {
+ var boxes string
+ s.rig.Run(scriptsOn(live),
+ send(emulation.SetDeviceMetricsOverride, emulation.SetDeviceMetricsOverrideParams{Width: width, Height: 900, DeviceScaleFactor: 1}),
+ chromedp.Navigate(s.rig.Origin+path), chromedp.WaitReady(barSearch), chromedp.Sleep(300*time.Millisecond),
+ harness.Into(&boxes, chromedp.Evaluate[string](bar)))
+ return boxes
+ }
+ off, on := load(false), load(true)
+ if off != on {
+ t.Errorf("%s at %dpx: the bar moved once scripts ran:\noff %s\non %s", path, width, off, on)
+ }
+ var shifts string
+ s.rig.Run(harness.Into(&shifts, chromedp.Evaluate[string](`JSON.stringify(window.__shifts || [])`)))
+ if shifts != "[]" {
+ t.Errorf("%s at %dpx: the bar shifted: %s", path, width, shifts)
+ }
+ }
+ }
+}
+
+// On a touch screen the lens is drawn as the other controls are and
+// takes a tap anywhere in 44px around its centre.
+func TestTheBarsSearchTakesATouchIn44px(t *testing.T) {
+ s := seedCards(t, 3)
+ var coarse bool
+ var misses string
+ s.rig.Run(
+ send(emulation.SetDeviceMetricsOverride, emulation.SetDeviceMetricsOverrideParams{Width: 1024, Height: 768, DeviceScaleFactor: 1}),
+ chromedp.Navigate(s.rig.Origin+"/t/t_customer"), chromedp.WaitVisible(barSearch),
+ // Touch emulation, then a reload so the page re-evaluates its
+ // media queries (TestNoZoomOnTap).
+ send(emulation.SetTouchEmulationEnabled, emulation.SetTouchEmulationEnabledParams{Enabled: true, MaxTouchPoints: 5}),
+ chromedp.Reload(), chromedp.WaitVisible(barSearch),
+ harness.Into(&coarse, chromedp.Evaluate[bool](`matchMedia('(pointer: coarse)').matches`)),
+ harness.Into(&misses, chromedp.Evaluate[string](`(function () {
+ var a = document.querySelector('`+barSearch+`'), b = a.getBoundingClientRect(), misses = [];
+ var x = (b.left + b.right) / 2, y = (b.top + b.bottom) / 2, r = 21.5;
+ [[-r, -r], [r, -r], [-r, r], [r, r], [0, -r], [0, r], [-r, 0], [r, 0]].forEach(function (d) {
+ if (!a.contains(document.elementFromPoint(x + d[0], y + d[1]))) misses.push(d.join(","));
+ });
+ return misses.join(" ") + (misses.length ? " (drawn " + b.width + "x" + b.height + ")" : "");
+})()`)),
+ send(emulation.SetTouchEmulationEnabled, emulation.SetTouchEmulationEnabledParams{Enabled: false}),
+ )
+ if !coarse {
+ t.Fatal("the touch-screen emulation did not apply; this would measure desktop styles")
+ }
+ if misses != "" {
+ t.Errorf("a tap misses the lens at %s", misses)
+ }
+}