Skip to content

Add role="alert" to flashed messages so screen readers announce them#970

Merged
jhpyle merged 1 commit into
jhpyle:masterfrom
goosfrabba:a11y/flash-messages-role-alert
Jul 13, 2026
Merged

Add role="alert" to flashed messages so screen readers announce them#970
jhpyle merged 1 commit into
jhpyle:masterfrom
goosfrabba:a11y/flash-messages-role-alert

Conversation

@goosfrabba

Copy link
Copy Markdown
Contributor

What this fixes

The server-rendered flashed-message banner in base.html has no ARIA role, so screen readers do not announce success or error messages.

Concretely: when an interview e-mails its documents, docassemble calls Flask's flash("Your documents will be e-mailed to ...", 'success'), which is rendered by this block in base.html. A screen reader user presses the button, the page reloads, and they hear nothing to confirm the documents were sent. This matters most for the people docassemble-based tools serve, including blind users filling out court and benefits forms on their own.

The fix

Add role="alert" to the flashed-message <div>, matching the JavaScript-injected notification in config.py (NOTIFICATION_MESSAGE), which already carries role="alert". Both code paths render the same alert markup; this makes the server-rendered one consistent so both are announced. One line, no visible change for sighted users.

Addresses SuffolkLITLab#47.

The server-rendered flashed-message banner in base.html had no ARIA role, so
screen readers did not announce success or error messages. For example, after
an interview e-mails its documents, the "Your documents will be e-mailed to ..."
confirmation is a Flask flash rendered by this block, and a screen reader user
heard nothing to confirm it was sent.

The equivalent JavaScript-injected notification in config.py (NOTIFICATION_MESSAGE)
already uses role="alert". This makes the server-rendered path consistent so both
are announced.

Addresses SuffolkLITLab#47.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jhpyle jhpyle merged commit 8a89244 into jhpyle:master Jul 13, 2026
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