Skip to content

Commit

Permalink
BCTHEME-229 Product carousel with related products - arrows not working
Browse files Browse the repository at this point in the history
  • Loading branch information
yurytut1993 committed Sep 25, 2020
1 parent 797b3da commit c23c059
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## Draft
- Product carousel with related products - arrows not working. [#1828](https://github.com/bigcommerce/cornerstone/pull/1828)
- Create unified focus styling in Cornerstone. [#1812](https://github.com/bigcommerce/cornerstone/pull/1812)
- Review link in quick modal focused twice. [#1797](https://github.com/bigcommerce/cornerstone/pull/1797)
- Fixed product image doesn't change on click when viewing a product with multiple images in IE11 [#1748](https://github.com/bigcommerce/cornerstone/pull/1748)
Expand Down
8 changes: 4 additions & 4 deletions assets/js/theme/common/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const arrowAriaLabling = ($arrowLeft, $arrowRight, currentSlide, lastSlide) => {

const arrowAriaLabelBaseText = $arrowLeft.attr('aria-label');

const isInit = arrowAriaLabelBaseText.includes(['NUMBER']);
const isInit = arrowAriaLabelBaseText.includes('[NUMBER]');
const valueToReplace = isInit ? '[NUMBER]' : integerRegExp;

const leftGoToNumber = currentSlide === 1 ? lastSlide : currentSlide - 1;
Expand All @@ -40,10 +40,10 @@ const arrowAriaLabling = ($arrowLeft, $arrowRight, currentSlide, lastSlide) => {

const onCarouselChange = (event, carousel) => {
const { options: { prevArrow, nextArrow }, currentSlide, slideCount } = carousel;
const $target = $(event.target);

setSlideTabindexes($(event.target).find('.slick-slide'));

arrowAriaLabling($(prevArrow), $(nextArrow), currentSlide + 1, slideCount);
setSlideTabindexes($target.find('.slick-slide'));
arrowAriaLabling($target.find(prevArrow), $target.find(nextArrow), currentSlide + 1, slideCount);
};

export default function () {
Expand Down
8 changes: 4 additions & 4 deletions templates/components/products/carousel.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"slidesToShow": 2,
"slidesToScroll": 1,
"slide": ".js-product-slide",
"prevArrow": ".js-product-prev-arrow",
"nextArrow": ".js-product-next-arrow",
"prevArrow": "{{#if customArrowClass}}.{{customArrowClass}}{{/if}}.js-product-prev-arrow",
"nextArrow": "{{#if customArrowClass}}.{{customArrowClass}}{{/if}}.js-product-next-arrow",
"responsive": [
{
"breakpoint": 800,
Expand All @@ -26,14 +26,14 @@
]
}'>
{{#if products.length '>' 1}}
<button aria-label="{{lang 'carousel.arrowAriaLabel'}} {{products.length}}" class="js-product-prev-arrow slick-prev slick-arrow"></button>
<button aria-label="{{lang 'carousel.arrowAriaLabel'}} {{products.length}}" class="{{#if customArrowClass}}{{customArrowClass}} {{/if}}js-product-prev-arrow slick-prev slick-arrow"></button>
{{/if}}
{{#each products}}
<div class="productCarousel-slide js-product-slide">
{{> components/products/card settings=../settings theme_settings=../theme_settings customer=../customer event="list" position=(add @index 1)}}
</div>
{{/each}}
{{#if products.length '>' 1}}
<button aria-label="{{lang 'carousel.arrowAriaLabel'}} {{products.length}}" class="js-product-next-arrow slick-next slick-arrow"></button>
<button aria-label="{{lang 'carousel.arrowAriaLabel'}} {{products.length}}" class="{{#if customArrowClass}}{{customArrowClass}} {{/if}}js-product-next-arrow slick-next slick-arrow"></button>
{{/if}}
</section>
6 changes: 3 additions & 3 deletions templates/components/products/tabs.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
{{#if product.related_products}}
<div role="tabpanel" aria-hidden="false" class="tab-content has-jsContent is-active" id="tab-related">
{{#if settings.data_tag_enabled}}
{{> components/products/carousel products=product.related_products columns=6 list="Related Products"}}
{{> components/products/carousel products=product.related_products columns=6 customArrowClass='js-related-product-arrow' list="Related Products"}}
{{else}}
{{> components/products/carousel products=product.related_products columns=6}}
{{> components/products/carousel products=product.related_products columns=6 customArrowClass='js-related-product-arrow'}}
{{/if}}
</div>
{{/if}}

{{#if product.similar_by_views}}
<div role="tabpanel" aria-hidden="{{#if product.related_products}}true{{else}}false{{/if}}" class="tab-content has-jsContent{{#unless product.related_products}} is-active{{/unless}}" id="tab-similar">
{{> components/products/carousel products=product.similar_by_views columns=6 list="Customers Also Viewed"}}
{{> components/products/carousel products=product.similar_by_views columns=6 list="Customers Also Viewed" customArrowClass='js-viewed-product-arrow' }}

</div>
{{/if}}
Expand Down

0 comments on commit c23c059

Please sign in to comment.