Skip to content

P0: fix(a11y): announce authentication errors - #224

Merged
aspiers merged 7 commits into
mainfrom
split-pr165/accessible-error-announcements
Jul 31, 2026
Merged

P0: fix(a11y): announce authentication errors#224
aspiers merged 7 commits into
mainfrom
split-pr165/accessible-error-announcements

Conversation

@aspiers

@aspiers aspiers commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Give authentication errors standard alert and live-region semantics so screen-reader users hear failures when the page updates.

Changes

  • Announce interactive sign-in, account-login, recovery, and demo errors
  • Add alert semantics to the shared server-rendered error page
  • Document the accessibility improvement with a changeset

Testing

  • pnpm format:check
  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm test:coverage

Screenshots

The visual error treatment is intentionally unchanged. DOM inspection on this deployed page confirmed that the banner is now exposed as role=alert so assistive technology announces it.

Authentication error banner

Notes

Summary by CodeRabbit

  • Accessibility Improvements
    • Improved screen-reader announcements for authentication errors across sign-in, one-time-code verification, account recovery, and handle selection.
    • Added announcements for handle availability updates and repeated or identical errors.
    • Improved error and timeout message handling so updates are announced clearly and consistently.
    • Applied the same accessible error announcements to the demo client.

aspiers and others added 4 commits July 29, 2026 01:11
The error banners on the OAuth login, account-login, and recovery
forms were plain divs / paragraphs. When an error appeared (or
updated) screen-reader users got no announcement — the error
silently changed and the user kept thinking the form had accepted
their input.

Add ARIA live-region semantics so updates announce naturally:
- Main login flash banner (#error-msg): role=status aria-live=polite
  (the polite intent is correct — errors should announce on
  update without interrupting whatever the user was doing)
- Server-rendered <p class="error"> banners on account-login and
  recovery: role=alert (these are static at render time, so the
  default assertive announcement on first render is appropriate)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The demo's sign-in error banner was a plain <div>. When an error
appeared screen-reader users got no announcement — visual users
saw the red banner, screen-reader users had no idea anything had
changed.

role="alert" matches the auth-service error banners in the
previous commits (which got role=status / role=alert) and tells
assistive tech to announce the message immediately.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The shared renderError() helper produces every styled HTML
fallback page (Sign-in session expired, internal failures,
session not found, …). The error message <p> was a plain
paragraph; screen-reader users got no announcement when these
pages loaded.

role="alert" tells assistive tech to announce immediately on
page render. Matches the role=alert treatment we just gave the
inline server-rendered error banners on account-login and
recovery.

One-character behaviour change; no test fixtures depend on the
exact HTML.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Jul 30, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: bd1d0d2

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Jul 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
epds-demo Ready Ready Preview Jul 31, 2026 5:02pm

Request Review

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Authentication errors now use accessible alert or status semantics across auth-service, shared rendering, and the demo client. The login page atomically replaces live-region content so repeated errors are announced. Handle availability feedback is linked to the input and announced politely.

Changes

Authentication accessibility

Layer / File(s) Summary
Atomic login error announcements
packages/auth-service/src/routes/login-page.ts
The login page uses a polite live region. Flash messages, timeout notices, and inline error actions replace the region content atomically. Clearing errors removes its child nodes.
Form error announcement semantics
packages/auth-service/src/routes/account-login.ts, packages/auth-service/src/routes/recovery.ts, packages/shared/src/render-error.ts, packages/demo/src/app/components/LoginForm.tsx, .changeset/announce-auth-errors.md
Authentication error messages use role="alert". Existing escaping, styling, and displayed text remain unchanged. The changeset documents the accessibility updates.
Handle availability feedback
packages/auth-service/src/routes/choose-handle.ts
The handle input references its availability feedback with aria-describedby. The feedback uses a polite live region, and populated server errors use alert semantics.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: copilot, kzoeps

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary accessibility change: announcing authentication errors to screen-reader users.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch split-pr165/accessible-error-announcements

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@railway-app

railway-app Bot commented Jul 30, 2026

Copy link
Copy Markdown

🚅 Deployed to the ePDS-pr-224 environment in ePDS

Service Status Web Updated (UTC)
@certified-app/auth-service ✅ Success (View Logs) Web Jul 31, 2026 at 5:02 pm
@certified-app/demo ✅ Success (View Logs) Web Jul 30, 2026 at 1:42 pm
@certified-app/demo untrusted ✅ Success (View Logs) Web Jul 30, 2026 at 1:42 pm
@certified-app/pds-core ✅ Success (View Logs) Web Jul 30, 2026 at 1:41 pm

@railway-app
railway-app Bot temporarily deployed to ePDS / ePDS-pr-224 July 30, 2026 13:38 Destroyed
@coveralls-official

coveralls-official Bot commented Jul 30, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 30649473082

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage remained the same at 57.281%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • 4 coverage regressions across 2 files.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

4 previously-covered lines in 2 files lost coverage.

File Lines Losing Coverage Coverage
packages/auth-service/src/routes/account-login.ts 3 0.0%
packages/auth-service/src/routes/choose-handle.ts 1 0.0%

Coverage Stats

Coverage Status
Relevant Lines: 3069
Covered Lines: 1753
Line Coverage: 57.12%
Relevant Branches: 1910
Covered Branches: 1099
Branch Coverage: 57.54%
Branches in Coverage %: Yes
Coverage Strength: 6.06 hits per line

💛 - Coveralls

@aspiers aspiers changed the title fix(a11y): announce authentication errors P0: fix(a11y): announce authentication errors Jul 30, 2026
@aspiers
aspiers marked this pull request as ready for review July 30, 2026 14:31
Copilot AI review requested due to automatic review settings July 30, 2026 14:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@aspiers

aspiers commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

aspiers and others added 3 commits July 31, 2026 18:00
Adding role=status/aria-live to #error-msg was not sufficient on its
own — the way showFlash mutated the region defeated it in two ways.

The region is display:none until an error fires, and showFlash wrote
textContent *before* setting display:block. A hidden element is
excluded from the accessibility tree, so the text landed while the
live region had no "before" state to diff against; assistive tech
could legitimately announce nothing. Unhide first, then mutate.

Assigning textContent in place also meant a repeated identical
message was not a DOM mutation at all. Re-submitting a bad OTP
yields the same "Invalid code" string, so the second failure was
silent — precisely the "user thinks the form accepted their input"
case this branch set out to fix. Build content off-DOM and swap it
in via replaceChildren so every failure is a real mutation.

Both concerns are now funnelled through one setFlash() helper, which
also fixes the double-announcement in showErrorWithAction and the
aborted-flow notice: each appended its action button *after*
showFlash had already made the region live, so the message and its
button announced as two separate updates. Building the whole content
in a fragment makes each of them a single announcement.

textContent remains the only sink for caller-supplied strings, so
reflected better-auth errors still cannot be interpolated as HTML.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The choose-handle page was missed by the earlier commits in this
branch. Two separate gaps:

The server-rendered error banner used the same <div class="error">
pattern as account-login and recovery, so it gets the same
role=alert. Only the populated branch needs it — the empty
placeholder is never written to by this page's script.

More significantly, #handle-status had no live-region semantics at
all. It is the sole feedback channel for whether a handle is free
("Checking…" / "Available!" / "Already taken." / format errors) and
it gates the Create button via submitBtn.disabled. Screen-reader
users therefore got no availability feedback whatsoever, and hit a
button that had been silently disabled with no stated reason.

aria-live=polite rather than assertive because setStatus() fires on
every debounced keystroke; assertive would interrupt the user
mid-type. aria-describedby also associates the status with the input
so it is read on focus, not only on change.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Widens the existing changeset to match what the branch now does:
handle selection is a newly covered surface, and repeated identical
failures announcing each time is a user-visible behaviour change
worth calling out separately from the initial role/aria additions.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 31, 2026 17:00
@railway-app
railway-app Bot temporarily deployed to ePDS / ePDS-pr-224 July 31, 2026 17:00 Destroyed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@sonarqubecloud

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/auth-service/src/routes/login-page.ts (1)

657-657: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use CSS classes for flash-region visibility.

Line 657 sets initial visibility with inline display:none. Lines 1015 and 1076 then change inline display values at runtime. Add a .hidden class and toggle that class instead.

Proposed fix
-    <div id="error-msg" class="flash-msg" style="display:none;" role="status" aria-live="polite"></div>
+    <div id="error-msg" class="flash-msg hidden" role="status" aria-live="polite"></div>

+    .flash-msg.hidden { display: none; }

-        errorEl.style.display = 'block';
+        errorEl.classList.remove('hidden');

-        errorEl.style.display = 'none';
+        errorEl.classList.add('hidden');

As per coding guidelines, “Use CSS classes to control visibility (hidden, active) rather than inline display style except for dynamic values set at render time.”

Also applies to: 1012-1015, 1070-1076

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/auth-service/src/routes/login-page.ts` at line 657, Replace the
inline display styling on the error flash region with the existing or newly
defined hidden CSS class, and update the visibility logic around the relevant
error-message handling functions to add or remove that class instead of
assigning inline display values. Preserve the current shown/hidden behavior and
target the error region identified by error-msg.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/auth-service/src/routes/login-page.ts`:
- Line 657: Replace the inline display styling on the error flash region with
the existing or newly defined hidden CSS class, and update the visibility logic
around the relevant error-message handling functions to add or remove that class
instead of assigning inline display values. Preserve the current shown/hidden
behavior and target the error region identified by error-msg.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: bcb68292-9cae-4331-934e-74542cafd25b

📥 Commits

Reviewing files that changed from the base of the PR and between 7bce175 and bd1d0d2.

📒 Files selected for processing (7)
  • .changeset/announce-auth-errors.md
  • packages/auth-service/src/routes/account-login.ts
  • packages/auth-service/src/routes/choose-handle.ts
  • packages/auth-service/src/routes/login-page.ts
  • packages/auth-service/src/routes/recovery.ts
  • packages/demo/src/app/components/LoginForm.tsx
  • packages/shared/src/render-error.ts

@aspiers
aspiers enabled auto-merge July 31, 2026 17:30
@aspiers
aspiers disabled auto-merge July 31, 2026 17:30
@aspiers
aspiers merged commit a6cf09d into main Jul 31, 2026
24 checks passed
@aspiers
aspiers deleted the split-pr165/accessible-error-announcements branch July 31, 2026 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants