-
Notifications
You must be signed in to change notification settings - Fork 20
Issue #3517035 by richardgaunt, joshua1234511, fionamorrison23: WCAG - Focus lands in wrong place upon form submission when error present #1443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| // CivicTheme status-messages.js | ||
| (function ($, Drupal) { | ||
| Drupal.behaviors.ctFocusErrorSummary = { | ||
| attach: function (context, settings) { | ||
| // Wait for DOM update after AJAX or normal load | ||
| setTimeout(function () { | ||
| // Find any element with id starting with 'error-summary-' | ||
| var $error = $('[id^="error-summary-"]', context).first(); | ||
| if ($error.length) { | ||
| $error.attr('tabindex', '-1'); // ensure focusable (in case) | ||
| $error.focus(); | ||
| } | ||
| }, 30); | ||
| } | ||
| }; | ||
| })(jQuery, Drupal); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| // CivicTheme status-messages.js | ||
| (function ($, Drupal) { | ||
| Drupal.behaviors.ctFocusErrorSummary = { | ||
| attach: function (context, settings) { | ||
| // Wait for DOM update after AJAX or normal load | ||
| setTimeout(function () { | ||
| // Find any element with id starting with 'error-summary-' | ||
| var $error = $('[id^="error-summary-"]', context).first(); | ||
| if ($error.length) { | ||
| $error.attr('tabindex', '-1'); // ensure focusable (in case) | ||
| $error.focus(); | ||
| } | ||
| }, 30); | ||
| } | ||
| }; | ||
| })(jQuery, Drupal); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,11 +6,14 @@ | |
| #} | ||
| {% for type, messages in message_list %} | ||
| {% for message in messages %} | ||
| {% set id_suffix = type == 'error' ? loop.parent.loop.index ~ '-' ~ loop.index : '' %} | ||
| {% set id_attr = type == 'error' ? 'id="error-summary-' ~ id_suffix ~ '" tabindex="-1"' : '' %} | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| {% include 'civictheme:message' with { | ||
| title: status_headings[type] ? status_headings[type] : type|capitalize, | ||
| content: message|render, | ||
| type: (type == 'status' or type == 'info') ? 'information' : type, | ||
| vertical_spacing: 'both', | ||
| attributes: id_attr | ||
|
||
| } only %} | ||
| {% endfor %} | ||
| {% endfor %} | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Critical: Code duplication between theme and starter kit.
This file is identical to
web/themes/contrib/civictheme/assets/js/status-messages/status-messages.js. Having duplicate code in both the main theme and starter kit creates a maintenance burden where changes must be synchronized across both files.Recommended approach:
Since this is accessibility-critical functionality, the main theme version should handle it. The starter kit should either:
If duplication is intentional (e.g., for easier customization), add a comment explaining that this file mirrors the parent theme's version and must be kept in sync:
🤖 Prompt for AI Agents