Skip to content

Commit

Permalink
fix(storefront): BCTHEME-346 add announcement for shipping estimator …
Browse files Browse the repository at this point in the history
…error messages
  • Loading branch information
bc-alexsaiannyi committed Dec 28, 2020
1 parent babdd27 commit 386d6f8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## Draft
- Added announcement on shipping estimator errors. [#1932](https://github.com/bigcommerce/cornerstone/pull/1932)

## 5.0.0 (12-14-2020)
- Parse HTML entities in jsContext. [#1917](https://github.com/bigcommerce/cornerstone/pull/1917)
Expand Down
10 changes: 10 additions & 0 deletions assets/js/theme/cart/shipping-estimator.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,22 @@ export default class ShippingEstimator {
}

initFormValidation() {
const shippingEstimatorAlert = $('.shipping-quotes');

this.shippingEstimator = 'form[data-shipping-estimator]';
this.shippingValidator = nod({
submit: `${this.shippingEstimator} .shipping-estimate-submit`,
});

$('.shipping-estimate-submit', this.$element).on('click', event => {
// estimator error messages are being injected in html as a result
// of user submit; clearing and adding role on submit provides
// regular announcement of these error messages
if (shippingEstimatorAlert.attr('role')) {
shippingEstimatorAlert.removeAttr('role');
}

shippingEstimatorAlert.attr('role', 'alert');
// When switching between countries, the state/region is dynamic
// Only perform a check for all fields when country has a value
// Otherwise areAll('valid') will check country for validity
Expand Down
2 changes: 1 addition & 1 deletion templates/components/cart/shipping-estimator.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@
<button class="button button--primary button--small shipping-estimate-submit">{{lang 'cart.shipping_estimator.estimate_shipping'}}</button>
</dl>
</form>
<div class="shipping-quotes"></div>
<div class="shipping-quotes" role="alert" aria-atomic="true" aria-live="assertive"></div>
</div>

0 comments on commit 386d6f8

Please sign in to comment.