oficina / docs Public

••• gives focus back to itself after a command

Fable on #179 (minor): a command run from ••• (Paged, Infinite, Print…)
closed the menu and left focus on the menu bar's item it ran from, which
is not drawn on a phone, so focus fell to the top of the page. It comes
back to •••'s button now; a command that opens a dialog still brings it
back when the dialog closes. TestThePhoneDocumentScreen checks it after
Paged and failed without it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev ef449394ca2e85819815c977bfc60120b829f2fd parent 02c2122
2 files changed, +16 −4
  • internal/docs/brand/phone.js +5 −3
  • internal/docs/phone_browser_test.go +11 −1
diff --git a/internal/docs/brand/phone.js b/internal/docs/brand/phone.js
index 3b90ae5..5ed117c 100644
--- a/internal/docs/brand/phone.js
+++ b/internal/docs/brand/phone.js
@@ -116,11 +116,13 @@
e.preventDefault();
close();
item.click();
- // A command that opened a dialog (word count, the shortcuts sheet)
- // returns focus to ••• when it closes: the menu bar's item it ran
- // is not drawn on a phone.
+ // Focus comes back to •••, where the person was: the menu bar's item
+ // the command ran from is not drawn on a phone, so focus would fall
+ // to the page's top. A command that opened a dialog (word count, the
+ // shortcuts sheet) brings it back when the dialog closes.
var dialog = document.querySelector("dialog[open]");
if (dialog && summary) dialog.addEventListener("close", function () { summary.focus(); }, { once: true });
+ else if (summary) summary.focus();
});
}
diff --git a/internal/docs/phone_browser_test.go b/internal/docs/phone_browser_test.go
index 146daf6..8f7af3e 100644
--- a/internal/docs/phone_browser_test.go
+++ b/internal/docs/phone_browser_test.go
@@ -145,8 +145,18 @@ func TestThePhoneDocumentScreen(t *testing.T) {
t.Errorf("%d of •••'s editor rows are still disabled once the editor has mounted", p.Disabled)
}
+ // A command run from ••• closes it and leaves focus on ••• (Fable on
+ // #179): the menu bar's item it ran is not drawn on a phone.
+ var back struct{ Open, OnMore, Paged bool }
+ run("Paged from •••", chromedp.Click(chromedp.CSS(`[data-docs-proxy="view_paged"]`)), settle,
+ evalInto(&back, `({ Open: document.querySelector('[docs-more]').open, OnMore: document.activeElement === document.querySelector('[docs-more] > summary'), Paged: document.querySelector('[docs-canvas]').getAttribute('data-view') === 'paged' })`))
+ if back.Open || !back.OnMore || !back.Paged {
+ t.Errorf("after Paged from •••: ••• open %v, focus on ••• %v, paged %v", back.Open, back.OnMore, back.Paged)
+ }
+ run("Infinite again", chromedp.Click(chromedp.CSS(`[docs-more] > summary`)), settle, chromedp.Click(chromedp.CSS(`[data-docs-proxy="view_infinite"]`)), settle)
+
// Rename turns the large title into its field, focused; Esc puts it back.
- run("Rename", chromedp.Click(chromedp.CSS(`[data-docs-rename]`)), settle)
+ run("Rename", chromedp.Click(chromedp.CSS(`[docs-more] > summary`)), settle, chromedp.Click(chromedp.CSS(`[data-docs-rename]`)), settle)
if p = probe("renaming"); !p.Editing || p.Active != "title" {
t.Errorf("••• ▸ Rename: editing %v, focus on %q", p.Editing, p.Active)
}