carlos / platform Public

claim page: focus the heading on a refused link, no ring on plain text

Paul (via platform-f6): the spent-link message paragraph took focus and
showed a focus ring around plain text. The heading (tabindex=-1) now
takes focus; the message keeps role=alert for screen readers; elements
focused only by script draw no outline (keyboard focus rings stay).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 4f25449778d8807877e744863584031889bf3bfd parent 3933abe
3 files changed, +9 −4
  • internal/console/static/demo_claim.js +3 −1
  • internal/console/templates/demo_claim.html +3 −2
  • internal/console/testdata/demo_claim_browser.mjs +3 −1

CI failed — run details

Intent

Attributed to this commit: 117 g CO₂e (9,521,979 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on claim-spent-focus, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.

diff --git a/internal/console/static/demo_claim.js b/internal/console/static/demo_claim.js
index d0239811b..a2edb27cb 100644
--- a/internal/console/static/demo_claim.js
+++ b/internal/console/static/demo_claim.js
@@ -259,7 +259,9 @@
const error = document.getElementById("claim-error");
error.textContent = messages.get(reason) || copy.failed;
error.hidden = false;
- error.focus();
+ // The heading takes focus (tabindex=-1); the message is announced by its
+ // alert role, and plain text never shows a focus ring.
+ heading.focus();
};
const visible = paint().then(() => wait(minimum));
fetch(kept ? "/demo/claim/kept" : "/demo/claim/intent", {
diff --git a/internal/console/templates/demo_claim.html b/internal/console/templates/demo_claim.html
index a22f78dab..791c373a6 100644
--- a/internal/console/templates/demo_claim.html
+++ b/internal/console/templates/demo_claim.html
@@ -15,6 +15,7 @@
#claim .claim-card { display: flex; align-items: flex-start; gap: 0.75rem; border: 1px solid var(--rule); border-radius: var(--rst-radius-sm); padding: 1rem; margin: 0 0 0.65rem; cursor: pointer; }
#claim .claim-card:has(:checked) { background: var(--accent-soft); border-color: var(--accent); }
#claim .claim-card:has(:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
+#claim [tabindex="-1"]:focus { outline: none; }
#claim .claim-card:has(:disabled) { color: var(--muted); background: var(--rst-surface-2); cursor: not-allowed; }
#claim .claim-card input { flex: none; width: 1.1rem; height: 1.1rem; margin-top: 0.25rem; accent-color: var(--accent); }
#claim .claim-card strong, #claim .claim-card .claim-detail { display: block; }
@@ -145,13 +146,13 @@
<span class="claim-life"><svg class="claim-clock" viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="6"/><path class="claim-hands" d="M8 4v4l3 2"/><path class="claim-tick" d="M4 8l3 3 5-6"/></svg><time class="claim-old" datetime="{{.EndTime}}" title="{{.EndTime}}"><span aria-hidden="true">{{.TimeLeft}}</span><span class="claim-sr-only">{{.TimeLeftAccessible}}</span></time><span class="claim-new">{{.Copy.done}}</span></span></div>
<span class="claim-burst" aria-hidden="true"><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i></span>
</div>{{end}}
-<h1 id="claim-heading">{{if eq .State "claimed"}}{{.Copy.completeHeading}}{{else if or (eq .State "stopping") (eq .State "aborted")}}{{.Copy.failureHeading}}{{else if .EmailPending}}{{.Copy.codeHeading}}{{else if and .Address (gt .Eligible 1)}}{{.Copy.accountsHeading}}{{else if eq .State "proof"}}{{.Copy.heading}}{{else}}{{.Copy.title}}{{end}}</h1>
+<h1 id="claim-heading" tabindex="-1">{{if eq .State "claimed"}}{{.Copy.completeHeading}}{{else if or (eq .State "stopping") (eq .State "aborted")}}{{.Copy.failureHeading}}{{else if .EmailPending}}{{.Copy.codeHeading}}{{else if and .Address (gt .Eligible 1)}}{{.Copy.accountsHeading}}{{else if eq .State "proof"}}{{.Copy.heading}}{{else}}{{.Copy.title}}{{end}}</h1>
{{if .Error}}<p role="alert">{{.Error}}</p><p><a href="/demo/claim">{{.Copy.back}}</a></p>{{end}}
{{if eq .State "no_accounts"}}<p>{{.Copy.identity}} <strong>{{.Address}}</strong></p><p>{{.Copy.noAccounts}}</p>
<fieldset class="claim-unavailable"><legend>{{.Copy.accountsLabel}}</legend>{{range .Accounts}}{{template "claim_card" .}}{{end}}</fieldset>{{end}}
<input type="hidden" name="nonce" value="{{.Nonce}}">
<input type="hidden" name="csrf" value="{{.CSRF}}">
-<p id="claim-error" role="alert" tabindex="-1" hidden></p>
+<p id="claim-error" role="alert" hidden></p>
<p id="claim-opening" role="status"{{if ne .State "missing"}} hidden{{end}}><span class="claim-spinner" aria-hidden="true"></span>{{.Copy.opening}}</p>{{if eq .State "missing"}}<p id="claim-missing" hidden>{{.Copy.missing}}</p>{{end}}
<div id="claim-expired-next" hidden><p>{{.Copy.newDemo}}</p><div class="claim-paste"><code id="claim-new-demo">{{.Copy.newDemoLine}}</code><button class="btn-sm btn-secondary" type="button" data-copy-target="claim-new-demo" data-copy="{{.Copy.copy}}" data-copied="{{.Copy.copied}}" hidden>{{.Copy.copy}}</button></div></div>
<p id="claim-kept-next" hidden><a href="/?next=%2Fdemo%2Fclaim">{{.Copy.consoleSignin}}</a></p>
diff --git a/internal/console/testdata/demo_claim_browser.mjs b/internal/console/testdata/demo_claim_browser.mjs
index 91953663a..bd5b3612c 100644
--- a/internal/console/testdata/demo_claim_browser.mjs
+++ b/internal/console/testdata/demo_claim_browser.mjs
@@ -58,7 +58,9 @@ try {
if (expectedError) {
await until('location.hash === "" && document.getElementById("claim-error")?.hidden === false');
assert.equal(await evaluate('document.getElementById("claim-error").textContent'), expectedError);
- assert.equal(await evaluate('document.activeElement.id'), 'claim-error');
+ assert.equal(await evaluate('document.activeElement.id'), 'claim-heading');
+ assert.equal(await evaluate('getComputedStyle(document.activeElement).outlineStyle'), 'none');
+ assert.equal(await evaluate('document.getElementById("claim-error").hasAttribute("tabindex")'), false);
assert.deepEqual(await evaluate('window.claimCSPViolations'), []);
const history = await call('Page.getNavigationHistory');
assert(history.entries.every(entry => !entry.url.includes('#')));