Send focus to error summary before single error

> If both sections of the page have errors and the page is submitted,
> focus moves to the mobile numbers section so screen reader users may
> not be aware of preceding errors - focus should move to a dedicated
> error summary at the top of the page.

Right now we use Javascript to focus the first error on a page (if any
errors are found). This commit adds more JS to then focus the error
summary, if there is one on the page. So this is where the focus will
rest.

It also makes some modifications to the ‘dangerous’ banner to make it
focusable, and to visually indicate that it is focused.
This commit is contained in:
Chris Hill-Scott
2017-02-13 12:11:32 +00:00
parent d2918486e9
commit cd7cb8884c
3 changed files with 13 additions and 1 deletions

View File

@@ -5,3 +5,5 @@ $(() => GOVUK.modules.start());
$(() => new GOVUK.SelectionButtons('.block-label input, .sms-message-option input'));
$(() => $('.error-message').eq(0).parent('label').next('input').trigger('focus'));
$(() => $('.banner-dangerous').eq(0).trigger('focus'));

View File

@@ -54,6 +54,10 @@
margin: 15px 0;
text-align: left;
&:focus {
outline: 3px solid $yellow;
}
.button {
@include button($error-colour);
margin-top: 10px;

View File

@@ -1,5 +1,11 @@
{% macro banner(body, type=None, with_tick=False, delete_button=None, subhead=None) %}
<div class='banner{% if type %}-{{ type }}{% endif %}{% if with_tick %}-with-tick{% endif %}'>
<div
class='banner{% if type %}-{{ type }}{% endif %}{% if with_tick %}-with-tick{% endif %}'
{% if type == 'dangerous' %}
role='group'
tabindex='-1'
{% endif %}
>
{% if subhead -%}
{{ subhead }}&ensp;
{%- endif -%}