diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ddb7c5ffc..20383e2041 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog ## Draft +- Write a Review modal cause TypeError. [#1899](https://github.com/bigcommerce/cornerstone/pull/1899) - Account >Payment Methods throws Server Error when using Cornerstone theme [#1898](https://github.com/bigcommerce/cornerstone/pull/1898) - Price in the cart is not updated when changing currency on mobile. [#1893](https://github.com/bigcommerce/cornerstone/pull/1893) diff --git a/assets/js/theme/product.js b/assets/js/theme/product.js index ad48754866..0c4c20020f 100644 --- a/assets/js/theme/product.js +++ b/assets/js/theme/product.js @@ -28,8 +28,6 @@ export default class Product extends PageManager { } }); - $(document).on('opened.fndtn.reveal', () => this.reviewModal.setupFocusableElements(WRITE_REVIEW)); - let validator; // Init collapsible @@ -40,9 +38,16 @@ export default class Product extends PageManager { videoGallery(); + this.bulkPricingHandler(); + const $reviewForm = classifyForm('.writeReview-form'); + + if ($reviewForm.length === 0) return; + const review = new Review($reviewForm); + $(document).on('opened.fndtn.reveal', () => this.reviewModal.setupFocusableElements(WRITE_REVIEW)); + $('body').on('click', '[data-reveal-id="modal-review-form"]', () => { validator = review.registerValidation(this.context); this.ariaDescribeReviewInputs($reviewForm); @@ -58,7 +63,6 @@ export default class Product extends PageManager { }); this.productReviewHandler(); - this.bulkPricingHandler(); } ariaDescribeReviewInputs($form) {