Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(storefront): BCTHEME-210 Carousel hidden when one or more of its images not found #1816

Merged
merged 2 commits into from
Oct 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## Draft
- Carousel hidden when one or more of its images not found. [#1816](https://github.com/bigcommerce/cornerstone/pull/1816)
- Rating and Other filter sections should be accessible by keyboard. [#1838](https://github.com/bigcommerce/cornerstone/pull/1838)
- Fixed header logo focus border for voiceover and browser. [#1831](https://github.com/bigcommerce/cornerstone/pull/1831)
- Unified browsers list that we support. [#1836](https://github.com/bigcommerce/cornerstone/pull/1836)
Expand Down
17 changes: 10 additions & 7 deletions assets/js/theme/common/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ const setSlideTabindexes = ($slides) => {
});
};

const showCarouselIfSlidesAnalizedSetup = ($carousel) => {
const analizedSlides = [];
const showCarouselIfSlidesAnalyzedSetup = ($carousel) => {
const analyzedSlides = [];
return ($slides) => ($slide) => {
analizedSlides.push($slide);
if ($slides.length === analizedSlides.length) {
analyzedSlides.push($slide);
if ($slides.length === analyzedSlides.length) {
$carousel.addClass('is-visible');
}
};
Expand Down Expand Up @@ -77,14 +77,14 @@ export default function () {

const $heroCarousel = $carouselCollection.filter('.heroCarousel');
const $slidesNodes = $heroCarousel.find('.heroCarousel-slide');
const showCarouselIfSlidesAnalized = showCarouselIfSlidesAnalizedSetup($heroCarousel)($slidesNodes);
const showCarouselIfSlidesAnalyzed = showCarouselIfSlidesAnalyzedSetup($heroCarousel)($slidesNodes);

$slidesNodes.each((index, element) => {
const $element = $(element);
const isContentBlock = !!$element.find('.heroCarousel-content').length;

if (isContentBlock) {
showCarouselIfSlidesAnalized($element);
showCarouselIfSlidesAnalyzed($element);
return true;
}

Expand All @@ -108,7 +108,10 @@ export default function () {
}
});

showCarouselIfSlidesAnalized($element);
showCarouselIfSlidesAnalyzed($element);
})
.error(() => {
showCarouselIfSlidesAnalyzed($element);
});
});

Expand Down