a11y: fix WCAG 2.2 AA and Uutilsynet audit findings

Tag autocomplete combobox pattern (WCAG 2.1.1, 4.1.2, 4.1.3):
- Add role="combobox", aria-expanded, aria-haspopup to tag input
- Implement arrow key navigation (up/down) through suggestions
- Add Space key support alongside Enter for selecting tags
- Manage aria-activedescendant to track highlighted option
- Add Escape to close suggestions
- Add aria-live="polite" status region announcing suggestion count
- Add aria-selected state on options
- Tag suggestions now have stable IDs for activedescendant

Focus visibility (WCAG 2.4.7):
- Remove outline:none on tag suggestions, replace with visible
  2px solid outline on :focus-visible

Contrast (WCAG 1.4.3):
- Replace opacity:0.5 on disabled rows with muted text color
  and strikethrough on username (maintains 4.5:1 ratio)

Structure and semantics (WCAG 1.3.1):
- Fix heading hierarchy H1→H3 skip in import.html (now H2)
- Replace <nav> misuse for fave actions with div[role="group"]
- Add aria-label="Administrasjonsmeny" to admin dashboard nav
- Wrap admin users table in responsive scrollable region
- Remove redundant "Bilde for:" prefix from image alt text
- Make error page H1 descriptive: "Feil 404: Ikke funnet"
- Add .sr-only utility class for screen-reader-only content
- Add hreflang="en" to English-language external link

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ole-Morten Duesund 2026-03-29 17:54:24 +02:00
commit a9d84a4de8
14 changed files with 171 additions and 41 deletions

View file

@ -51,7 +51,7 @@
<p>
<small>
Drevet av <a href="https://kode.naiv.no/olemd/favoritter" target="_blank" rel="noopener">Favoritter</a>
— fri programvare under <a href="https://www.gnu.org/licenses/agpl-3.0.html" target="_blank" rel="noopener">AGPL-3.0</a>
— fri programvare under <a href="https://www.gnu.org/licenses/agpl-3.0.html" target="_blank" rel="noopener" hreflang="en">AGPL-3.0</a>
</small>
</p>
</footer>

View file

@ -25,7 +25,7 @@
</article>
</div>
<nav>
<nav aria-label="Administrasjonsmeny">
<ul>
<li><a href="{{basePath}}/admin/users" role="button" class="outline">Brukere</a></li>
<li><a href="{{basePath}}/admin/tags" role="button" class="outline">Merkelapper</a></li>

View file

@ -29,6 +29,7 @@
</article>
{{with .Data}}
<div class="table-responsive" role="region" aria-label="Brukertabell" tabindex="0">
<table role="grid">
<thead>
<tr>
@ -68,5 +69,6 @@
{{end}}
</tbody>
</table>
</div>
{{end}}
{{end}}

View file

@ -2,8 +2,7 @@
{{with .Data}}
<article>
<hgroup>
<h1>{{.Code}}</h1>
<p>{{.Message}}</p>
<h1>Feil {{.Code}}: {{.Message}}</h1>
</hgroup>
{{if eq .Code 404}}
<p>Siden du leter etter finnes ikke. Den kan ha blitt flyttet eller slettet.</p>

View file

@ -28,7 +28,7 @@
{{with .Fave}}
{{if .ImagePath}}
<img src="{{basePath}}/uploads/{{.ImagePath}}"
alt="Bilde for: {{.Description}}">
alt="{{.Description}}">
{{end}}
<header>
@ -56,7 +56,7 @@
<footer>
<small>Lagt til {{.CreatedAt.Format "02.01.2006"}}</small>
{{if $d.IsOwner}}
<nav class="fave-actions">
<div class="fave-actions" role="group" aria-label="Handlinger for favoritt">
<a href="{{basePath}}/faves/{{.ID}}/edit" role="button" class="outline">Rediger</a>
<button
hx-delete="{{basePath}}/faves/{{.ID}}"
@ -65,7 +65,7 @@
class="outline secondary"
data-redirect="{{basePath}}/faves"
>Slett</button>
</nav>
</div>
{{end}}
</footer>
{{end}}

View file

@ -55,17 +55,21 @@
value="{{.Tags}}"
placeholder="film, sci-fi, favoritt"
autocomplete="off"
role="combobox"
aria-expanded="false"
aria-haspopup="listbox"
aria-autocomplete="list"
aria-controls="tag-suggestions"
aria-describedby="tags-help"
hx-get="{{basePath}}/tags/search"
hx-trigger="keyup changed delay:300ms"
hx-target="#tag-suggestions"
hx-params="*"
hx-vals='{"q": ""}'
aria-describedby="tags-help"
aria-autocomplete="list"
aria-controls="tag-suggestions">
<small id="tags-help">Skriv for å søke i eksisterende merkelapper. Maks {{maxTags}} stk.</small>
hx-vals='{"q": ""}'>
<small id="tags-help">Skriv for å søke i eksisterende merkelapper. Maks {{maxTags}} stk. Bruk piltaster for å velge.</small>
</label>
<ul id="tag-suggestions" role="listbox" class="tag-suggestions" aria-label="Merkelappforslag"></ul>
<div id="tag-status" class="sr-only" aria-live="polite"></div>
<fieldset>
<legend>Synlighet</legend>

View file

@ -14,7 +14,7 @@
<article class="fave-card" role="listitem">
{{if .ImagePath}}
<img src="{{basePath}}/uploads/{{.ImagePath}}"
alt="Bilde for: {{.Description}}"
alt="{{.Description}}"
loading="lazy">
{{end}}
<header>

View file

@ -12,7 +12,7 @@
<article class="fave-card" role="listitem">
{{if .ImagePath}}
<img src="{{basePath}}/uploads/{{.ImagePath}}"
alt="Bilde for: {{.Description}}"
alt="{{.Description}}"
loading="lazy">
{{end}}
<header>

View file

@ -15,7 +15,7 @@
<details>
<summary>Forventet format</summary>
<h3>JSON</h3>
<h2>JSON</h2>
<pre><code>[
{
"description": "Blade Runner 2049",
@ -24,7 +24,7 @@
"tags": ["film", "sci-fi"]
}
]</code></pre>
<h3>CSV</h3>
<h2>CSV</h2>
<pre><code>description,url,privacy,tags
Blade Runner 2049,https://example.com,public,"film,sci-fi"</code></pre>
</details>

View file

@ -57,7 +57,7 @@
<article class="fave-card" role="listitem">
{{if .ImagePath}}
<img src="{{basePath}}/uploads/{{.ImagePath}}"
alt="Bilde for: {{.Description}}"
alt="{{.Description}}"
loading="lazy">
{{end}}
<header>

View file

@ -11,7 +11,7 @@
<article class="fave-card" role="listitem">
{{if .ImagePath}}
<img src="{{basePath}}/uploads/{{.ImagePath}}"
alt="Bilde for: {{.Description}}"
alt="{{.Description}}"
loading="lazy">
{{end}}
<header>

View file

@ -1,6 +1,8 @@
{{range .}}<li role="option"
{{range $i, $tag := .}}<li role="option"
id="tag-option-{{$i}}"
class="tag-suggestion"
onclick="addTag(this, '{{.Name}}')"
onkeydown="if(event.key==='Enter'){addTag(this, '{{.Name}}')}"
tabindex="0">{{.Name}}</li>
aria-selected="false"
onclick="addTag(this, '{{$tag.Name}}')"
onkeydown="if(event.key==='Enter'||event.key===' '){event.preventDefault();addTag(this, '{{$tag.Name}}')}"
tabindex="-1">{{$tag.Name}}</li>
{{end}}