Skip to content

fix(a11y-gate): audit a story only once it has finished rendering - #523

Merged
Ardnived merged 3 commits into
mainfrom
fix/a11y-gate-settled-515
Nov 27, 2026
Merged

Ardnived merged 3 commits into
mainfrom
fix/a11y-gate-settled-515

Conversation

@Ardnived

@Ardnived Ardnived commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • The a11y gate no longer audits a story while its loading skeleton is up, so views--event-·-sticky-register reads all 12 stops on every run
  • A story the gate still reads mid-render is now reported as unsettled, instead of quietly passing or failing on a partial page
  • Joined: the keyboard walk had read 0 stops on views--calendar and atoms--drawer and passed anyway. It now walks both, and an empty walk is a finding. Joined because it is the same class of silent partial read the ticket targets
  • Joined: the calendar walk then caught a real gap. The month agenda's selected day showed no focus indicator, and it now draws the app's focus outline

Change outline

Flow — one story's audit

settled() now waits for the widget's own placeholder marker (data-sy-loading, LOADING_ATTR) to clear. A recount after the audit checks whether the gate read the whole page.

 run()                                              scripts/check-a11y.mjs
   goto story
-  settled(page)                                    # first mutation + 250ms quiet
+  settled(page, { waitForLoading })                # …and no [data-sy-loading] left
+    placeholder still up when quiet → keep waiting (its swap restarts the window)
+    PLACEHOLDER_STORIES (organisms--skeleton) → don't wait for the marker
   pageAudit()
+    stopsBefore = stops()                          # counted before axe runs
     axe.run, tap probe, stamp data-a11y-order
     stops = stops()                                # shared helper, also behind __a11y.recount
+  after 100ms (RECHECK_MS): recount stops, unstamped controls, placeholders
+  unsettledDetail(audit, now, placeholderStory)
+    counts differ / unstamped > 0 / placeholder up → failure `unsettled`, skip all other verdicts
   tap verdicts
   keyboardWalk(count)
-    document.body.focus()                          # no-op: walk began wherever focus was
+    focus a tabindex=-1 anchor prepended to <body>
-    one Tab per stop, a skipped Radix focus guard included
+    a skipped focus guard spends no press; bounded at count × 3 + 2 presses
+  walk reached 0 of N > 0 stops → failure `keyboard-walk`

Behaviour — the calendar's selected day

Schedule-X marks the agenda's selected day with an inset ring, and focus left that ring unchanged. The selected day is the grid's one Tab stop, so tabbing into the grid showed nothing.

 src/styles/globals.css
+.sx-calendar .sx__month-agenda-day:focus-visible → focus-outline

Behaviour — the report

 ## Accessibility gate — N findings
+N stories, M controls measured.                    # printed on red too, so runs compare

Preview

  • Calendar story: press Tab until focus reaches the month grid. The selected day should now show the focus outline. The PR's -design preview alias carries the same story once it is built.

Test results

  • Lean gate --full: ✓ (lint, typecheck, 2655 unit tests, build with assert-css-scoped, size)
  • Targeted specs: scripts/check-a11y.test.ts 17 passed
  • pnpm test:a11y after pnpm ladle:build: repeated full runs measured 688 controls each, about 49s per run (41s before). The count was 689 earlier the same day on both the old and the new code, which points to the date-driven calendar content, not this change.
  • Walks: views--calendar reaches 9 of 9 stops and atoms--drawer 1 of 1 (0 of each before). No story now walks 0 of a non-zero count.

Manual verification

  1. pnpm ladle:build, then for i in 1 2 3 4 5; do node scripts/check-a11y.mjs | grep 'controls measured'; done. The count should be identical on every run.
  2. In the calendar story, Tab into the month grid and check that the focus outline is visible on the selected day, in both light and dark mode.

Notes for reviewer

  • The cause is React, not chunk latency. react-dom 19's FALLBACK_THROTTLE_MS holds a Suspense boundary's content back at least 300ms after its fallback commits. That is longer than the 250ms quiet window. views--event was also read on its skeleton, not only the sticky story. The marker covers skeleton phases only, so the quiet window must stay: at 50ms, unmarked states (the boot spinner, lazy mapbox-gl, a late row in views--countries) read partial in 7 of 18 reads.
  • Why the calendar walk was empty. Schedule-X's month agenda runs a MutationObserver that calls focus() on its day cell after any attribute change inside it. The audit's own data-a11y-order stamping counts as one. document.body.focus() cannot take focus back, because the body is not focusable. So the walk started on the day cell, and its first Tab left the page.
  • Security review: src/styles/ triggers it. The change is one CSS rule nested under .sx-calendar, and assert-css-scoped confirms every rule is confined to .sy-atlas. There is no data path.
  • The gate is still red locally on main, for a reason unrelated to this PR. organisms--mapbox reports "Mapbox homepage" at 88×24 when a real token loads the map.
  • Dismissed review findings:
    • "Other stories may hold a skeleton at rest." Dismissed: a survey of all 58 stories found only organisms--skeleton does, and it is listed.
    • "The probe may change the counts." Dismissed: repeated full runs flagged nothing.
    • "Missing re-arm." Dismissed: a placeholder is always removed by a DOM mutation the observer sees.
    • "The spec imports Skeleton.tsx." Dismissed: Skeleton.test.tsx already loads it in the same node lane.
Detail
  • aria-busy was rejected as the readiness signal. atoms--button and organisms--load-more show it on purpose at rest.
  • The recount waits a fixed 100ms instead of running a second quiet window. The late stories landed 4–31ms after the audit's read. The fixed wait saves about 9s per run over a second 250ms settle.
  • stopsBefore exists for slow machines. Under 4× CPU throttle the content swap moves into axe.run, where both later counts agree and only the pre-axe count differs.
  • atoms--inputs--radio-group (5 of 13) and molecules--form-field (13 of 15) still walk short of their count. That is expected: a roving group is one Tab stop holding several elements. Only an empty walk is a finding.
  • Unrelated formatting was dropped. The first commit had Prettier noise in it, and the second commit removes it. Prettier is not enforced on .mjs.

Closes #515

🤖 Generated with Claude Code

Ardnived and others added 2 commits November 26, 2026 15:57
settled() now holds out while a loading placeholder (data-sy-loading) is on
the page, so a view whose body is a lazy chunk is audited on its content,
not its skeleton. After the audit the gate settles again and recounts the
tab stops; a changed count, an unstamped control, or a placeholder still up
at the cap fails the story as `unsettled` instead of passing or failing it
on a partial read.

Closes #515

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Count tab stops before axe runs as well as after the probe, so content
landing while axe runs is caught; recount after a fixed 100ms instead of a
second quiet window (58s -> 49s); pass settle options as one object; drop
the unrelated reformatting; state the cause as React's 300ms Suspense
reveal throttle and keep the quiet window for unmarked pending states.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sydevs-dispatcher

sydevs-dispatcher Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

🤖 no session running

recent dispatches
  • 12:52Z review-pr · attempt 3 · session · done
  • 12:52Z review-pr · attempt 3 · session
  • 03:22Z review-pr · attempt 2 · session · timed out
  • 03:22Z review-pr · attempt 2 · session
  • 00:00Z review-pr · attempt 1 · session · timed out

Written by the sydevs dispatcher. Sessions never edit this comment.

@sydevs-dispatcher sydevs-dispatcher Bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 27, 2026
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Pending to Working in SYDevelopers Technical Roadmap Nov 27, 2026
The keyboard walk started from wherever the page had put focus, since
document.body.focus() is a no-op: Schedule-X's month agenda focuses its day
cell on the audit's own attribute stamping, so views--calendar walked 0 of 9
stops and passed. Start from a focused anchor at the top instead, stop a
skipped Radix focus sentinel spending a press (atoms--drawer walked 0 of 1),
and fail a walk that reaches none of a story's stops as `keyboard-walk`.

The calendar's walk then found a real gap: the agenda's selected day is the
grid's one Tab stop and focus painted nothing over its selection ring. It
now draws the app's focus outline.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
sahajatlas-design 5a25d45 Nov 27 2026, 12:28 AM

@Ardnived
Ardnived merged commit 7fe9e90 into main Nov 27, 2026
14 checks passed
@Ardnived
Ardnived deleted the fix/a11y-gate-settled-515 branch November 27, 2026 00:30
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Working to Done in SYDevelopers Technical Roadmap Nov 27, 2026
@sydevs-dispatcher sydevs-dispatcher Bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 27, 2026
@sydevs-dispatcher sydevs-dispatcher Bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Nov 27, 2026
@sydevs-dispatcher sydevs-dispatcher Bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 27, 2026
@Ardnived Ardnived removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

fix(a11y-gate): audit a story only once it has finished rendering

1 participant