Leave focus where clicked; reduced motion; avatar contrast and target
- A click outside the ⋯ menu closes it and leaves focus where the person clicked; only Escape puts focus back on ⋯. - With reduced motion, Home behind the phone's chat sheet no longer blurs or dims either: it simply shows. - The avatar (the link to Settings) inherited the page's pale text, at 1.8:1 on its gradient in dark mode; it now keeps its dark initials, 6.5:1 in both themes. - On a wide screen the avatar is a 32px circle inside a 44px target. Tests for each: the click-through in TestAskPanel, Home's filter under reduced motion in TestMobile, and the avatar's contrast and target in TestHomeApps.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5 files changed,
+31
−14
internal/browsertest/ask_test.go+10 −0internal/browsertest/layout_test.go+5 −1internal/browsertest/mobile_test.go+3 −2internal/look/static/app.css+9 −4internal/look/static/ask.js+4 −7
diff --git a/internal/browsertest/ask_test.go b/internal/browsertest/ask_test.go| index 930501c..74132d1 100644 |
| --- a/internal/browsertest/ask_test.go |
| +++ b/internal/browsertest/ask_test.go |
| @@ -182,6 +182,16 @@ func TestAskPanel(t *testing.T) { |
| drive(t, rig, chromedp.Click(chromedp.CSS(more)), chromedp.WaitVisible(chromedp.CSS(menuLink)), |
| chromedp.Click(chromedp.CSS(`#ask-panel .thread`)), chromedp.Poll[chromedp.Void](`!document.querySelector("#ask-panel details.ask-more").open`, chromedp.WithPollingTimeout(3*time.Second))) |
| + // A click elsewhere (here, into the message field) closes the menu and |
| + // leaves focus where the person clicked; only Escape goes back to ⋯. |
| + drive(t, rig, chromedp.Click(chromedp.CSS(more)), chromedp.WaitVisible(chromedp.CSS(menuLink)), |
| + chromedp.Click(chromedp.CSS(`#ask-text`)), |
| + chromedp.Poll[chromedp.Void](`!document.querySelector("#ask-panel details.ask-more").open`, chromedp.WithPollingTimeout(3*time.Second)), |
| + chromedp.Sleep(100*time.Millisecond)) |
| + if got := harness.Evaluate[string](rig, `document.activeElement.id || document.activeElement.outerHTML.slice(0, 60)`); got != "ask-text" { |
| + t.Errorf("after clicking the message field with the menu open, focus is on %s", got) |
| + } |
| + |
| // With the menu open and focus moved on past Open Equipo to Close, the |
| // first Escape still closes only the menu and puts focus back on ⋯. |
| drive(t, rig, chromedp.Click(chromedp.CSS(more)), chromedp.WaitVisible(chromedp.CSS(menuLink)), |
diff --git a/internal/browsertest/layout_test.go b/internal/browsertest/layout_test.go| index 1b8d3bb..062cfec 100644 |
| --- a/internal/browsertest/layout_test.go |
| +++ b/internal/browsertest/layout_test.go |
| @@ -153,7 +153,11 @@ func TestHomeApps(t *testing.T) { |
| t.Errorf("%s at %dx800: %s", scheme, w, got) |
| } |
| if w == 1280 { |
| - checkContrast(t, rig, "Home, "+scheme, ".lede", ".app-grid .label", ".dock .label") |
| + checkContrast(t, rig, "Home, "+scheme, ".lede", ".app-grid .label", ".dock .label", "a.me") |
| + if got := harness.Evaluate[string](rig, `(() => { const r = document.querySelector("a.me").getBoundingClientRect(), bar = document.querySelector(".topbar").getBoundingClientRect(); |
| + return r.width >= 44 && r.height >= 44 && r.top >= bar.top - 0.5 && r.bottom <= bar.bottom + 0.5 ? "" : r.width + "x" + r.height + " at " + r.top + "-" + r.bottom; })()`); got != "" { |
| + t.Errorf("%s: the avatar (Settings) target is %s, want 44px inside the top bar", scheme, got) |
| + } |
| layoutShot(t, rig, "desktop-home-"+scheme) |
| } |
| } |
diff --git a/internal/browsertest/mobile_test.go b/internal/browsertest/mobile_test.go| index 82677d2..60be70e 100644 |
| --- a/internal/browsertest/mobile_test.go |
| +++ b/internal/browsertest/mobile_test.go |
| @@ -207,8 +207,9 @@ func TestMobile(t *testing.T) { |
| drive(t, rig, reducedMotion("dark", true), chromedp.Poll[chromedp.Void](`!document.querySelector("#ask-panel").open`, chromedp.WithPollingTimeout(3*time.Second)), |
| chromedp.Click(chromedp.CSS(`a.ask-icon`)), chromedp.Sleep(30*time.Millisecond)) |
| if got := harness.Evaluate[string](rig, `(() => { const d = document.querySelector("#ask-panel").getBoundingClientRect(); |
| - return d.top + " " + getComputedStyle(document.querySelector("main.home")).transform; })()`); got != "0 none" { |
| - t.Errorf("with reduced motion the sheet is at %s (want 0 none)", got) |
| + const h = getComputedStyle(document.querySelector("main.home")); |
| + return d.top + " " + h.transform + " " + h.filter + " " + h.opacity; })()`); got != "0 none none 1" { |
| + t.Errorf("with reduced motion the sheet and Home are %q (want 0 none none 1: no slide, no scale, no blur or dimming)", got) |
| } |
| drive(t, rig, chromedp.KeyEvent("\u001b"), reducedMotion("dark", false)) |
diff --git a/internal/look/static/app.css b/internal/look/static/app.css| index a9392dc..19cb9ac 100644 |
| --- a/internal/look/static/app.css |
| +++ b/internal/look/static/app.css |
| @@ -391,7 +391,12 @@ a.app:hover { background: var(--hover); } |
| } |
| /* Links drawn as tiles and buttons. */ |
| -a.app, a.me { color: inherit; text-decoration: none; } |
| +a.app { color: inherit; text-decoration: none; } |
| +/* The avatar is the way to Settings: dark initials on its warm gradient in |
| + both themes (AA on every part of it), a 32px circle drawn inside a 44px |
| + target whose padding overhangs the top bar's own. */ |
| +a.me { color: var(--ink); text-decoration: none; } |
| +.topbar a.me { width: 44px; height: 44px; margin: -6px -6px -6px 0; padding: 6px; background-clip: content-box; flex: none; } |
| /* The wordmark on inner pages is the way back to Home: a 44px target. */ |
| a.wordmark { color: inherit; text-decoration: none; min-height: 44px; border-radius: 8px; } |
| .notepad + form { margin-top: 16px; } |
| @@ -488,7 +493,7 @@ main { min-height: 100dvh; } |
| a.ask { display: none; } |
| .ask-icon { display: grid; } |
| .ask, a.ask { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } |
| - .me { flex: none; width: 44px; height: 44px; font-size: 14px; } |
| + .me, .topbar a.me { flex: none; width: 44px; height: 44px; margin: 0; padding: 0; font-size: 14px; } |
| /* A springboard: a compact greeting, four columns of apps on the |
| atmosphere, and a glass dock fixed to the foot of the screen. */ |
| .hello { margin-top: 26px; font-size: 30px; } |
| @@ -535,11 +540,11 @@ main { min-height: 100dvh; } |
| } |
| /* With reduced motion the chat just shows: no slide, no scale, and Home |
| - does not step back (it still dims behind a phone's sheet). */ |
| + does not step back, blur or dim behind it. */ |
| @media (prefers-reduced-motion: reduce) { |
| dialog.ask-panel, dialog.ask-panel[open], main.home { transition: none; transform: none; animation: none; } |
| @starting-style { dialog.ask-panel[open] { transform: none; opacity: 1; } } |
| - body:has(dialog.ask-panel[open]) main.home { transform: none; } |
| + body:has(dialog.ask-panel[open]) main.home { transform: none; filter: none; opacity: 1; } |
| } |
| @keyframes sheet-up { from { transform: translateY(100%); } } |
diff --git a/internal/look/static/ask.js b/internal/look/static/ask.js| index e386b82..6b279f7 100644 |
| --- a/internal/look/static/ask.js |
| +++ b/internal/look/static/ask.js |
| @@ -260,16 +260,13 @@ function start(root) { |
| setTurn(out.turn); |
| }); |
| - // The ⋯ menu: Escape and a click elsewhere close it, and focus goes back |
| - // to ⋯. Without scripts it is a plain <details>. |
| + // The ⋯ menu: Escape and a click elsewhere close it. Escape gives focus |
| + // back to ⋯; a click leaves it where the person clicked. Without scripts |
| + // it is a plain <details>. |
| const menus = [...root.querySelectorAll("details.ask-more")]; |
| for (const menu of menus) { |
| - const button = menu.querySelector("summary"); |
| document.addEventListener("click", (e) => { |
| - if (menu.open && !menu.contains(e.target)) { |
| - menu.open = false; |
| - button.focus(); |
| - } |
| + if (menu.open && !menu.contains(e.target)) menu.open = false; |
| }); |
| menu.querySelector(".ask-menu a").addEventListener("click", () => { menu.open = false; }); |
| } |