Skip to content

Commit

Permalink
Merge pull request #2230 from huntario/BCTHEME-1092
Browse files Browse the repository at this point in the history
fix(storefront): BCTHEME-1092 Make screen reader say all errors then …
  • Loading branch information
bc-as authored Jul 28, 2022
2 parents 1a3409c + cdc38d0 commit 02cad1c
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Incorrect translation key for Diners Club card type. [#2237](https://github.com/bigcommerce/cornerstone/issues/2237).
- Make screen reader say error messages when editing customer account. [#2233](https://github.com/bigcommerce/cornerstone/pull/2233)
- Bump webpack-bundle-analyzer [#2229]https://github.com/bigcommerce/cornerstone/pull/2229
- Make screen reader say all errors then each error while tabbing. [#2230]https://github.com/bigcommerce/cornerstone/pull/2230

## 6.5.0 (06-24-2022)
- Category icons do not appear in Search Form [#2221]https://github.com/bigcommerce/cornerstone/pull/2221
Expand Down
21 changes: 13 additions & 8 deletions assets/js/theme/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export default class Auth extends PageManager {
const validationModel = validation($createAccountForm, this.context);
const createAccountValidator = nod({
submit: `${this.formCreateSelector} input[type='submit']`,
tap: announceInputErrorMessage,
delay: 0,
});
const $stateElement = $('[data-field-type="State"]');
const emailSelector = `${this.formCreateSelector} [data-field-type='EmailAddress']`;
Expand Down Expand Up @@ -170,15 +170,20 @@ export default class Auth extends PageManager {
);
}

$createAccountForm.on('submit', event => {
createAccountValidator.performCheck();
$createAccountForm.on('submit', (event) => {
this.submitAction(event, createAccountValidator);
});
}

if (createAccountValidator.areAll('valid')) {
return;
}
submitAction(event, validator) {
validator.performCheck();

event.preventDefault();
});
if (validator.areAll('valid')) {
return;
}
event.preventDefault();
const earliestError = $('span.form-inlineMessage:first').prev('input');
earliestError.focus();
}

/**
Expand Down
2 changes: 2 additions & 0 deletions templates/components/common/forms/checkbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
data-input
data-label="{{label}}"
class="form-checkbox"
aria-labelledby="{{id}}"
aria-live="polite"
{{#if checked}}checked{{/if}}
{{#if private_id}}data-field-type="{{private_id}}"{{/if}}
>
Expand Down
6 changes: 6 additions & 0 deletions templates/components/common/forms/date.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
data-label="month"
data-input
aria-required="{{required}}"
aria-labelledby="{{id}}"
aria-live="polite"
{{#if private_id}}data-field-type="{{private_id}}"{{/if}}
>
{{> components/common/forms/date-options month isRequired=required}}
Expand All @@ -25,6 +27,8 @@
data-label="day"
data-input
aria-required="{{required}}"
aria-labelledby="{{id}}"
aria-live="polite"
{{#if private_id}}data-field-type="{{private_id}}"{{/if}}
>
{{> components/common/forms/date-options day isRequired=required}}
Expand All @@ -37,6 +41,8 @@
data-label="year"
data-input
aria-required="{{required}}"
aria-labelledby="{{id}}"
aria-live="polite"
{{#if private_id}}data-field-type="{{private_id}}"{{/if}}
>
{{> components/common/forms/date-options year isRequired=required}}
Expand Down
2 changes: 2 additions & 0 deletions templates/components/common/forms/multiline.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
data-label="{{label}}"
rows="{{rows}}"
aria-required="{{required}}"
aria-labelledby="{{id}}"
aria-live="polite"
data-input
class="form-input"
{{#if private_id}}data-field-type="{{private_id}}"{{/if}}
Expand Down
2 changes: 2 additions & 0 deletions templates/components/common/forms/number.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
id="{{id}}_input"
name="{{name}}"
aria-required="{{required}}"
aria-labelledby="{{id}}"
aria-live="polite"
{{#if private_id}}data-field-type="{{private_id}}"{{/if}}
>
</div>
2 changes: 2 additions & 0 deletions templates/components/common/forms/radio.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
data-label="{{label}}"
data-input
aria-required="{{required}}"
aria-labelledby="{{id}}"
aria-live="polite"
{{#if checked}}checked{{/if}}
{{#if private_id}}data-field-type="{{private_id}}"{{/if}}
>
Expand Down
2 changes: 2 additions & 0 deletions templates/components/common/forms/select.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
data-label="{{label}}"
data-input
aria-required="{{required}}"
aria-labelledby="{{id}}"
aria-live="polite"
name="{{name}}"
{{#if private_id}} data-field-type="{{private_id}}" {{/if}}
>
Expand Down
4 changes: 4 additions & 0 deletions templates/components/common/forms/selectortext.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
value="{{value}}"
class="form-input"
aria-required="{{required}}"
aria-labelledby="{{id}}"
aria-live="polite"
data-label="{{label}}"
data-input
/>
Expand All @@ -22,6 +24,8 @@
<select name="{{name}}"
class="form-select"
aria-required="{{required}}"
aria-labelledby="{{id}}"
aria-live="polite"
id="{{id}}_select"
data-label="{{label}}"
data-input
Expand Down
2 changes: 2 additions & 0 deletions templates/components/common/forms/text.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
data-label="{{label}}"
data-input
aria-required="{{required}}"
aria-labelledby="{{id}}"
aria-live="polite"
{{#if value}} value="{{value}}"{{/if}}
{{#if maxlength}}maxlength="{{maxlength}}"{{/if}}
{{#if placeholder}} placeholder="{{placeholder}}"{{/if}}
Expand Down

0 comments on commit 02cad1c

Please sign in to comment.