diff --git a/CHANGELOG.md b/CHANGELOG.md index bac41c1743..b52f55f8b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog ## Draft +- Reviews pagination navigation buttons reload the whole page and does not open the Reviews tab. [#2047](https://github.com/bigcommerce/cornerstone/pull/2047) - Added settings for payment banners. [#2021](https://github.com/bigcommerce/cornerstone/pull/2021) - Use https:// for schema markup. [#2039](https://github.com/bigcommerce/cornerstone/pull/2039) - Update focus tooltip styles contrast to achieve accessibility AA Complaince. [#2047](https://github.com/bigcommerce/cornerstone/pull/2047) diff --git a/assets/js/theme/product/reviews.js b/assets/js/theme/product/reviews.js index d6aba7c5e3..b0dd94a880 100644 --- a/assets/js/theme/product/reviews.js +++ b/assets/js/theme/product/reviews.js @@ -12,11 +12,12 @@ export default class { }); this.$reviewsContent = $('#product-reviews'); + this.$reviewsContentList = $('#productReviews-content', this.$reviewsContent); this.$collapsible = $('[data-collapsible]', this.$reviewsContent); this.initLinkBind(); this.injectPaginationLink(); - this.collapseReviews(); + this.setupReviews(); } /** @@ -24,26 +25,26 @@ export default class { * The browser jumps to the review page and should expand the reviews section */ initLinkBind() { - const $content = $('#productReviews-content', this.$reviewsContent); - - $('#productReview_link').on('click', () => { - $('.productView-reviewTabLink').trigger('click'); - if (!$content.hasClass('is-open')) { - this.$collapsible.trigger(CollapsibleEvents.click); - } - }); + $('#productReview_link').on('click', () => this.showReviews()); } - collapseReviews() { + setupReviews() { // We're in paginating state, do not collapse if (window.location.hash && window.location.hash.indexOf('#product-reviews') === 0) { - return; + return this.showReviews(); } // force collapse on page load this.$collapsible.trigger(CollapsibleEvents.click); } + showReviews() { + $('.productView-reviewTabLink').trigger('click'); + if (!this.$reviewsContentList.hasClass('is-open')) { + this.$collapsible.trigger(CollapsibleEvents.click); + } + } + /** * Inject ID into the pagination link */