# Accessibility after a perfect Lighthouse score: the WCAG 2.2 problems a scan can't see

By Farhad Rezaei (https://farhad-rezaei.com) · Published 2026-11-27
Canonical: https://farhad-rezaei.com/blog/accessibility-after-a-perfect-lighthouse-score
Product: Portfolio (https://farhad-rezaei.com)

> Automated accessibility scores read markup at one moment, so they miss behaviour: a sticky header broken by overflow-x: hidden, focus rings under WCAG 2.2's 3:1 that fade further mid-transition, an accessible name that doesn't match the visible label, and focus dropped when the focused control is disabled. Scripted checks over scrolling, focus and transitions found them; the fixes were small CSS and ARIA changes.

Earlier this week I wrote about [prerendering my portfolio](https://farhad-rezaei.com/blog/prerendering-a-react-app-without-a-framework) so it reads fast on a phone. The site is a React and TypeScript single-page app in six languages, two of them right to left, with a sticky header, a language picker, a theme switch and a couple of small games. Lighthouse gave its accessibility a score of 100.

The sticky header still scrolled off the top of the page, on every screen size. For anyone who navigates with a keyboard or a screen magnifier, the menu, the language picker and the theme switch were gone after the first scroll, and getting them back meant scrolling all the way up again.

A building inspection works the same way. The inspector checks that every exit sign is there and lit, and the building passes. Nobody walks the route in the dark to see whether the door at the end opens. Automated checks look at what the markup says at one moment: whether a button has a name, whether static text has enough contrast. They don't scroll, they don't follow focus over time, and they don't watch a transition.

## Walking the route

So I walked it, with scripted checks in headless Chromium at widths from 360 to 1366 pixels, in English, Persian and Arabic. The checks scroll the page 2,500 pixels and read where the header is. They tab through the controls on the dark panels and compute the contrast of each focus ring against its background. They compare each control's accessible name with the text it shows. I read the focus handling in the code alongside them, state by state, for the small Morse-code game and the mobile menu. That pass found more than a dozen accessibility issues behind the perfect score. These are the ones that mattered most.

## A header that only looked sticky

After a 2,500-pixel scroll, the header's top edge sat at -2,500. Both `html` and `body` had `overflow-x: hidden`, which made `body` a scroll container, and a sticky element sticks to its nearest scrolling ancestor. That ancestor became `body`, a box that grows with its content and never actually scrolls, so the header simply moved with the page. Changing both rules to `overflow-x: clip` keeps the horizontal clipping without creating a scroll container. The same scripted scroll now reads 0.

![With overflow-x: hidden on html and body, the header scrolls away to -2500 after a 2,500-pixel scroll; with overflow-x: clip it stays at 0.](https://farhad-rezaei.com/images/blog/accessibility-after-a-perfect-lighthouse-score/sticky.svg)

## Focus you can see, names you can say

On the dark panels, the focus ring used the site's red, `#9d1521`, against a near-black `#0e0d0c`. That's about 2.4:1, under the 3:1 that WCAG 2.2 asks of focus indicators and other non-text contrast. It got worse mid-animation: the buttons used `transition: all`, which also faded the outline's colour, and during that fade the ring measured about 1.5:1. The dark panels now use the lighter accent the site already had for them, and the transitions name the properties they animate, so the outline is never mid-fade.

![Focus ring contrast on the dark panel: 2.4:1 for the red ring, 1.5:1 mid-transition, and 5.3:1 for the lighter accent, against the 3:1 minimum.](https://farhad-rezaei.com/images/blog/accessibility-after-a-perfect-lighthouse-score/contrast.svg)

The language picker showed "English" while its accessible name was "Language". Someone using voice control says what they see, "click English", and nothing has that name. The button's name now starts with its visible text, with "Language" added for screen readers only, and each option carries its own `lang` attribute, so فارسی and العربية are read in the right voice.

## Focus that vanished

The Morse game plays a pattern and then waits for the player to repeat it. While the pattern played, the tiles were `disabled`, including the one the keyboard player was standing on, and a disabled element can't hold focus. The browser dropped focus back to the top of the document, so a keyboard player was thrown out of the game every round. The tiles now use `aria-disabled` and ignore clicks while locked, so focus stays where it was.

The mobile menu had a smaller version of the same problem. Escape closed it but left focus nowhere, and the dimmed backdrop behind it was a focusable button with the same name as the menu button, a confusing extra stop. Escape now returns focus to the menu button, and the backdrop is for pointers only.

The rest were quick once found. The installable app was locked to portrait. The skip link stayed on the left edge in Persian and Arabic, so it now uses `inset-inline-start`. On the side-projects page, the status badges were about 2:1 against their background, and the headings skipped from the page title straight to the third level.

## How I checked it

I re-ran the checks against the deployed site. After the same 2,500-pixel scroll, the header sits at 0 at 360, 820 and 1366 pixels wide. The focus ring on the dark hero now measures 5.3:1, and the language picker's name reads "English, Language". Lighthouse still scores 100, as it did before any of this. The score didn't move because these problems were never visible to it.

## What carries over

- Treat a perfect automated score as the start of the review.
- Test behaviour over time: after a scroll, after a key press, in the middle of a transition.
- Start every accessible name with the label people can see.
- Never disable the element that currently has focus.
- If you ship right-to-left languages, use logical properties for anything that sits on one side.

For a visitor, the result is a site that keeps its controls in reach and never loses their place. The work behind it was small CSS and ARIA changes, but it came from treating accessibility as behaviour to check, not markup to pass, which is the same habit that keeps any product reliable after the first green build.

## Further reading

- Web Content Accessibility Guidelines (WCAG) 2.2: https://www.w3.org/TR/WCAG22/
- Understanding Success Criterion 2.5.3, Label in Name: https://www.w3.org/WAI/WCAG22/Understanding/label-in-name.html
- Understanding Success Criterion 1.4.11, Non-text Contrast: https://www.w3.org/WAI/WCAG22/Understanding/non-text-contrast.html
- overflow, including clip, on MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/overflow
