Commit 8877319a4c

8877319a4c1f350210337e72d3ff16370c41c5f2

parent: c56ef893fb

Verified · cmc ci/build: success ci/test: success

cmc <hello@cleberg.net> · 2026-09-20 04:50 UTC

web: no autofocus on the search and register forms

Focus jumped past the heading, the result count and the global search
page's filter navigation. The form is the first interactive thing on
each page, so the first Tab reaches it anyway.

The diff line-comment textarea keeps its autofocus: that form renders
only after the reader asks for it on a line, and with no JavaScript
autofocus is the only thing carrying focus across the reload.

Closes #238
internal/web/templates/globalsearch.html +1 −1
@@ -20,7 +20,7 @@
2020 {{if and .Query (not .QueryErr)}}<p class="meta">{{len .Results}} {{if eq (len .Results) 1}}result{{else}}results{{end}} for <q>{{.Query}}</q>{{if .Kind}} in {{.Kind}}{{end}}</p>{{end}}
2121</div>
2222<form method="get" action="/search" class="searchform">
23 <input type="search" name="q" aria-label="Search" value="{{.Query}}" placeholder="repository names and topics, issue and merge request text" autofocus>
23 <input type="search" name="q" aria-label="Search" value="{{.Query}}" placeholder="repository names and topics, issue and merge request text">
2424 {{if .Kind}}<input type="hidden" name="kind" value="{{.Kind}}">{{end}}
2525 <button type="submit" class="btn">Search</button>
2626</form>
internal/web/templates/register.html +1 −1
@@ -6,7 +6,7 @@
66{{else}}<p class="lede">Open registration. Your account activates once you verify your email.</p>{{end}}
77{{if .Error}}<p class="error" role="alert">{{.Error}}</p>{{end}}
88<form method="post" action="/register" class="signupform">
9<div class="field"><label for="username">Username</label><input type="text" id="username" name="username" value="{{.Username}}" required autofocus></div>
9<div class="field"><label for="username">Username</label><input type="text" id="username" name="username" value="{{.Username}}" required></div>
1010{{if eq .Mode "invite"}}<div class="field"><label for="invite">Invite code</label><input type="text" id="invite" name="invite" required></div>
1111{{else}}<div class="field"><label for="email">Email</label><input type="text" id="email" name="email" required></div>{{end}}
1212<div class="field"><label for="key">SSH public key</label>
internal/web/templates/search.html +1 −1
@@ -3,7 +3,7 @@
33{{define "content"}}
44<h1>Search</h1>
55<form method="get" action="/{{.Repo.OwnerName}}/{{.Repo.Name}}/search" class="searchform">
6 <input type="search" name="q" aria-label="Search file contents" value="{{.Query}}" placeholder="search file contents on {{.Ref}}" autofocus>
6 <input type="search" name="q" aria-label="Search file contents" value="{{.Query}}" placeholder="search file contents on {{.Ref}}">
77 <button type="submit" class="btn">Search</button>
88</form>
99{{if .QueryErr}}<p class="error" role="alert">{{.QueryErr}}</p>