Dev.to WebDev πŸ›  Dev πŸ‘ 0 πŸ“– 7 min read

I Audited My Own SaaS Apps for Accessibility. Zero htmlFor Across 150 Form Fields.

My studio site has a guide on app accessibility. It tells clients to target WCAG 2.2 AA, build accessible components once, and test every release. Good advice. This week I finally checked whether I follow it. I grepped

My studio site has a guide on app accessibility. It tells clients to target WCAG 2.2 AA, build accessible components once, and test every release. Good advice. This week I finally checked whether I follow it.

I grepped the two SaaS apps I run myself: VoiceDash (a white-label portal for Retell voice agents, Next.js, about 97 component files) and Upwork Scout (AI-matched Upwork job alerts, Next.js, a much smaller app). No axe run, no screen reader session yet. Just reading the code against the checklist, the way I would on a client audit.

The headline number: across both repos there are roughly 150 form controls and zero uses of htmlFor.

Finding 1: every label is a sibling, not a label

This is the pattern in almost every form I have written in the last year:

<label className="block text-xs font-medium text-gray-700 mb-1.5">Client Name *</label>
<input
  type="text" value={name} onChange={(e) => setName(e.target.value)} placeholder="Acme Corp"
  className="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500" required
/>

It looks labelled. It is not. The <label> has no htmlFor, the input has no id, and the input is not nested inside the label. To the browser these are two unrelated elements that happen to sit next to each other.

What that costs:

  • A screen reader focusing the input does not hear "Client Name". It falls back to the placeholder, so the field is announced as "Acme Corp, edit text". On Upwork Scout's filter inputs the placeholder is e.g. "WordPress", "urgent", "$5", which is a fine hint and a terrible name.
  • Clicking the label text does not focus the field. Small thing for a mouse user, bigger for someone with a tremor who relies on the larger click target.
  • The required asterisk in "Client Name *" is visual only.

The numbers: VoiceDash has 89 <label> elements and 133 inputs, with 0 id attributes on any input. Upwork Scout has 16 inputs. Its email signup on the landing page, the single most important field in the whole product, has no label at all. Placeholder [email protected], nothing else.

The only exceptions I found are two checkboxes in Upwork Scout where I happened to wrap the input inside the label, which gives an implicit association. That was luck, not intent.

The fix is boring, which is the point. In React 18+ I can do it with useId inside a small component, so it is impossible to forget:

function Field({ label, ...props }: { label: string } & React.InputHTMLAttributes<HTMLInputElement>) {
  const id = useId();
  return (
    <div>
      <label htmlFor={id} className="block text-xs font-medium text-gray-700 mb-1.5">{label}</label>
      <input id={id} {...props} />
    </div>
  );
}

That is the "build accessible components once" advice from the guide. I did not follow it because I never built a Field component in the first place. Every form is hand-rolled markup copied from the previous form, so the bug copied itself 89 times.

Finding 2: seven buttons with no name

I wrote a quick script to find <button> elements whose only content is a self-closing JSX element (a Lucide icon) and that have no aria-label. VoiceDash has 180 buttons; 7 of them are icon-only and nameless:

  • the close X on the New Client and Add Agent dialogs
  • a Plus in the AI analysis tab
  • a PhoneOff (end test call) in the widget tab
  • a Tag button that adds a tag to a call
  • a Trash2 delete on custom domains and a Download on conversations, both with a title but no aria-label

A screen reader announces the first five as just "button". The two with title are better than nothing, since browsers fall back to title for the accessible name, but tooltip-only naming is fragile and invisible to keyboard users.

Funny detail: the two buttons that do have aria-label ("Close" and "Actions") are in the billing UI, the newest part of the codebase. So I learned the habit at some point. I just never went back.

Upwork Scout came out clean on this check, 23 buttons and no nameless icons, mostly because it barely uses icons.

Finding 3: a switch that never says whether it is on

Upwork Scout's dashboard has a toggle to pause or resume job alerts:

<button
  onClick={() => save({ active: !me.active })}
  title={me.active ? "Alerts ON, click to pause" : "Alerts PAUSED, click to resume"}
  className={`h-8 w-14 rounded-full p-1 transition ${me.active ? "bg-accent" : "bg-line-strong"}`}
  aria-label="Toggle alerts"
>

I clearly tried here. There is an aria-label, and the title even carries the state. But aria-label wins the accessible name computation, so the title is ignored, and a screen reader hears "Toggle alerts, button" whether alerts are on or off. The state lives in the background color and the knob position. That is information conveyed by color and position alone.

The correct version is two attributes:

<button role="switch" aria-checked={me.active} aria-label="Job alerts" ...>

To be fair to past me, when alerts are paused an amber text banner appears saying so. That covers sighted users who miss the color. It does nothing for the announcement on the control itself.

Right next to that switch is a save indicator with a subtler bug. It never unmounts; it hides by color:

<span className={`text-sm ${saving ? "text-muted" : saved ? "text-accent" : "text-transparent"}`}>
  {saving ? "Saving…" : "Saved βœ“"}
</span>

text-transparent hides it from eyes only. The text "Saved βœ“" is in the DOM from page load, so a screen reader user reading the header hears "Saved" before they have changed anything. And because it is not an aria-live region, when a save actually happens nothing is announced. It is wrong in both directions.

Finding 4: modals that are just divs

VoiceDash has 7 modal overlays built as fixed inset-0 divs. Not one has role="dialog" or aria-modal. Only the billing UI listens for Escape. The whole codebase has a single programmatic .focus() call.

So when a dialog opens, keyboard focus stays on the button behind it. Tab moves through the page underneath the overlay. A screen reader user gets no announcement that a dialog appeared at all. This is the one I would fix first, because it breaks the core flows: creating a client and adding an agent both happen in these dialogs.

The fix here is not hand-rolling focus traps in seven places. It is the native <dialog> element with showModal(), which gives focus moving into the dialog, Escape to close, and an inert background for free, or a headless library if I want more control.

Finding 5: one grey that fails contrast

Upwork Scout's palette has two greys for secondary text. I ran both through the WCAG contrast formula:

Token On Ratio AA body text (4.5:1)
--color-muted #5b6878 page #fafbfc 5.48 pass
--color-muted-2 #9aa6b2 page #fafbfc 2.39 fail
accent #0e7a6f page 5.03 pass

muted-2 is used 11 times for real text, including the reassurance line directly under the signup form ("Free to start Β· no password Β· unsubscribe anytime") and the client line on showcase jobs. That line is doing conversion work, and a chunk of visitors can barely read it.

VoiceDash has a smaller version: its icon-only close buttons use text-gray-400 on white, 2.54:1, below the 3:1 that WCAG asks for non-text UI.

The fix is one token change. Darkening muted-2 until it clears 4.5:1 fixes all 11 places at once, which is the strongest argument for design tokens I have personally run into.

What I got right, mostly by accident

  • Both apps set <html lang="en">.
  • Every image I checked has alt.
  • No <div onClick> pretending to be a button, apart from one table cell that only stops event propagation.
  • VoiceDash inputs use focus:outline-none focus:ring-2, so focus stays visible. Upwork Scout removes the outline and only changes the border color on focus, which is visible but faint.

Why this happened

None of these are hard problems. Each fix is one or two attributes. They happened because:

  1. I never built shared form components, so nothing enforced the right markup.
  2. eslint-config-next is installed in both repos, but I never looked at which a11y rules it actually enforces, and nothing caught a label with no htmlFor.
  3. I test by clicking through with a mouse. Nothing in my workflow ever touches a keyboard-only path or a screen reader.

That third one is the real lesson. My guide says automated tools catch missing labels and low contrast, but whether someone can actually finish a flow needs manual testing with VoiceOver and a keyboard. I wrote that for clients and never applied it to myself.

What I am doing about it

Nothing below is shipped yet. In order:

  1. Native <dialog> for the seven VoiceDash modals.
  2. A Field component with useId, and a codemod-style pass to replace sibling labels.
  3. aria-label on the seven icon buttons, role="switch" + aria-checked on the alerts toggle, and an aria-live="polite" save indicator that actually unmounts.
  4. Darken muted-2.
  5. Add @axe-core/playwright to a smoke test of the signup and dashboard pages, and do one VoiceOver pass per release on the critical path.

I wrote earlier about an XR app quietly assuming a standing adult with two hands. Turns out my web apps quietly assume a mouse and good eyesight.

The full client-facing guide, with what WCAG 2.2 AA covers and what to ask a dev team, is on the Null Studio blog.

If you grep your own repo for htmlFor right now, what number do you get?

πŸ“° Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.