-
Notifications
You must be signed in to change notification settings - Fork 615
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(storefront): BCTHEME-425 Incorrect focus order for product carou…
…sels
- Loading branch information
1 parent
d59675f
commit b2ba337
Showing
10 changed files
with
94 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...me/common/carousel/utils/setTabindexes.js → ...me/common/carousel/utils/analizeSlides.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,26 @@ | ||
import updateTextWithLiveData from './updateTextWithLiveData'; | ||
import tooltipSetup from './tooltipSetup'; | ||
|
||
export default ($prevArrow, $nextArrow, activeSlideIdx, slidesQuantity, ariaLabel) => { | ||
export default ($prevArrow, $nextArrow, activeSlideIdx, slidesQuantity, isInfinite, ariaLabel) => { | ||
if (slidesQuantity < 2 || !$prevArrow || !$nextArrow) return; | ||
|
||
const activeSlideNumber = activeSlideIdx + 1; | ||
|
||
const prevSlideNumber = activeSlideIdx === 0 ? slidesQuantity : activeSlideNumber - 1; | ||
const arrowLeftText = updateTextWithLiveData(ariaLabel, prevSlideNumber, slidesQuantity); | ||
|
||
$prevArrow.attr('aria-label', arrowLeftText); | ||
$prevArrow.attr({ | ||
'aria-label': arrowLeftText, | ||
tabindex: !isInfinite && activeSlideIdx === 0 ? -1 : 0, | ||
}); | ||
tooltipSetup($prevArrow); | ||
|
||
const nextSlideNumber = activeSlideIdx === slidesQuantity - 1 ? 1 : activeSlideNumber + 1; | ||
const arrowRightText = updateTextWithLiveData(ariaLabel, nextSlideNumber, slidesQuantity); | ||
|
||
$nextArrow.attr('aria-label', arrowRightText); | ||
$nextArrow.attr({ | ||
'aria-label': arrowRightText, | ||
tabindex: !isInfinite && activeSlideIdx === slidesQuantity - 1 ? -1 : 0, | ||
}); | ||
tooltipSetup($nextArrow); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
assets/js/theme/common/carousel/utils/getActiveSlideIdxAndSlidesQuantity.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
export { default as activatePlayPauseButton } from './activatePlayPauseButton'; | ||
export { default as analizeSlides } from './analizeSlides'; | ||
export { default as arrowAriaLabling } from './arrowAriaLabling'; | ||
export { default as dotsSetup } from './dotsSetup'; | ||
export { default as getActiveSlideIdxAndSlidesQuantity } from './getActiveSlideIdxAndSlidesQuantity'; | ||
export { default as handleImageAspectRatio } from './handleImageAspectRatio'; | ||
export { default as handleImageLoad } from './handleImageLoad'; | ||
export { default as setTabindexes } from './setTabindexes'; | ||
export { default as tooltipSetup } from './tooltipSetup'; | ||
export { default as refreshFocus } from './refreshFocus'; | ||
export { default as updateTextWithLiveData } from './updateTextWithLiveData'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
export const FOCUSABLE_ELEMENTS_SELECTOR = '[href], button, input, textarea, select, details, [contenteditable="true"], [tabindex]'; | ||
|
||
export default ($prevArrow, $nextArrow, $dots, $slider, activeSlideIdx, slidesQuantity, isInfinite) => { | ||
if (isInfinite || !$prevArrow || !$nextArrow) return; | ||
|
||
if (activeSlideIdx === 0 && $prevArrow.is(':focus')) { | ||
$nextArrow.focus(); | ||
} else if (activeSlideIdx === slidesQuantity - 1 && $nextArrow.is(':focus')) { | ||
if ($dots) { | ||
$dots.children().first().find('[data-carousel-dot]').focus(); | ||
return; | ||
} | ||
|
||
const $firstActiveSlide = $slider.find('.slick-active').first(); | ||
|
||
if ($firstActiveSlide.is(FOCUSABLE_ELEMENTS_SELECTOR)) { | ||
$firstActiveSlide.focus(); | ||
} else $firstActiveSlide.find(FOCUSABLE_ELEMENTS_SELECTOR).first().focus(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters