Skip to article content
FrontendXLesson 17 / 20

Accessibility bug hunts

Turn a vague failure report into a reproduction, isolate the cause, form and falsify hypotheses, instrument the code, fix async and state bugs, lock the fix behind a regression test and review changes for real trade-offs.

intermediate · about 40 minutes · 2 exercises

  • Explain
  • Debug

What you will be able to do

#
  • Reproduce an accessibility bug with a keyboard path or an assistive technology.
  • Fix the semantic cause instead of patching the symptom.

Overview

#

An accessibility bug is a correctness bug: some users cannot complete the task. Hunt it the same way as any other bug, by reproducing it with a specific input and isolating the element that fails.

The reproduction is a keyboard or assistive-technology path, not a visual impression. Tab to the control, press Enter or Space, and check whether the action runs. Run a screen reader and check whether the control announces its role, name and state. These paths fail in ways a mouse and a screenshot never reveal.

The most common bug is a clickable div. It looks like a button, but it has no role, is not focusable and does not respond to the keyboard.

snippet.html
<!-- bug: a div with a click handler -->
<div class="btn" onclick="save()">Save</div>

The fix is the real element, which brings the role, the keyboard behaviour and the focus handling for free.

snippet.html
<!-- fixed: a real button -->
<button type="button" onclick="save()">Save</button>

The second common bug is a missing accessible name. An input with no label, or an icon-only button with no text, is announced as an unlabelled control. Give every control a name through a label, aria-label or visible text.

The third is focus management. Opening a dialog must move focus into it and trap it there, and closing it must return focus to the control that opened it. A single-page navigation must move focus to the new heading, or the screen reader stays on the old content.

The fourth is state that is conveyed by colour alone. An error shown only as a red border is invisible to a user who cannot see colour and silent to a screen reader. Add text or an icon and announce the change with a live region.

Automated tools such as axe catch missing names and contrast, but they cannot tell whether a keyboard path completes a task. The keyboard and screen-reader passes are the ones that find the bugs that matter.

Exercises

#

Reference answers and expected output are authored, not executed in this browser. Nothing you type is run, and there is no Run or Pass control on this page.

  1. Exercise 1Debug

    This control looks like a button but is a div with a click handler, so it cannot be reached or activated by keyboard. Replace it with the correct element and keep the same action.

    starter.html
    <div class="btn" onclick="save()">Save</div>

    Reveal the reference answer
    reference.html
    <button type="button" onclick="save()">Save</button>

    Authored expected output: The control is focusable, activates with Enter and Space, and is announced as a button by a screen reader.

    A real button element provides the role, focusability and keyboard activation that a div lacks. Setting type to button prevents an unintended form submit when the control sits inside a form.

  2. Exercise 2Explain

    Give a review rubric for an accessibility bug hunt on a dialog, listing the blocking issues and how you would reproduce each one.

    Reveal the reference answer
    reference.text
    Check that the trigger is a real button so it is focusable and keyboard operable. Check that opening the dialog moves focus into it and traps focus while it is open, and that closing it returns focus to the trigger. Check that the dialog has a role of dialog and an accessible name from a heading or aria-label. Check that every control inside has an accessible name and that errors are announced with a live region rather than colour alone. Check that pressing Escape closes the dialog. Reproduce each item with the keyboard only and once with a screen reader; an automated scan is a starting point, not the evidence.

    Authored expected output: A rubric covering the trigger, focus management, role and name, labelled controls and announced errors, each with a keyboard or screen-reader reproduction.

    Dialogs fail in a small number of predictable ways, so a checklist finds them quickly. Each item is only proven by a keyboard or screen-reader path, because automated scans cannot verify that a task can be completed.

Common misconceptions

#
  • A passing automated accessibility scan means the feature is accessible.
  • A div styled as a button is equivalent to a button.

Follow-up practice

#
  • debugging-review-18-security-review

Related resources

#

Your progress

#

Answers, drafts and completion marks are stored only in this browser. Nothing is sent to a server and no account is used.

Verification: authored. Answers and outputs on this page are authored reference material, not executed results.

© 2026 FrontendX. All rights reserved.