Skip to content

Commit

Permalink
fix(a11y): fixed issue with not working "enter" navigation on arrows
Browse files Browse the repository at this point in the history
fixes #7423
  • Loading branch information
nolimits4web committed Mar 28, 2024
1 parent 7a1cddd commit aac2dcf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
38 changes: 21 additions & 17 deletions src/modules/a11y/a11y.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -109,24 +109,28 @@ export default function A11y({ swiper, extendParams, on }) {
) {
if (!e.target.matches(classesToSelector(swiper.params.pagination.bulletClass))) return;
}
if (swiper.navigation && swiper.navigation.nextEl && targetEl === swiper.navigation.nextEl) {
if (!(swiper.isEnd && !swiper.params.loop)) {
swiper.slideNext();
}
if (swiper.isEnd) {
notify(params.lastSlideMessage);
} else {
notify(params.nextSlideMessage);
}
}
if (swiper.navigation && swiper.navigation.prevEl && targetEl === swiper.navigation.prevEl) {
if (!(swiper.isBeginning && !swiper.params.loop)) {
swiper.slidePrev();
if (swiper.navigation && swiper.navigation.prevEl && swiper.navigation.nextEl) {
const prevEls = makeElementsArray(swiper.navigation.prevEl);
const nextEls = makeElementsArray(swiper.navigation.nextEl);
if (nextEls.includes(targetEl)) {
if (!(swiper.isEnd && !swiper.params.loop)) {
swiper.slideNext();
}
if (swiper.isEnd) {
notify(params.lastSlideMessage);
} else {
notify(params.nextSlideMessage);
}
}
if (swiper.isBeginning) {
notify(params.firstSlideMessage);
} else {
notify(params.prevSlideMessage);
if (prevEls.includes(targetEl)) {
if (!(swiper.isBeginning && !swiper.params.loop)) {
swiper.slidePrev();
}
if (swiper.isBeginning) {
notify(params.firstSlideMessage);
} else {
notify(params.prevSlideMessage);
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/modules/navigation/navigation.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ export default function Navigation({ swiper, extendParams, on, emit }) {
swiper.el.querySelectorAll(el).length === 1
) {
res = swiper.el.querySelector(el);
} else if (res.length === 1) {
res = res[0];
}
}
if (el && !res) return el;
Expand Down Expand Up @@ -95,11 +97,11 @@ export default function Navigation({ swiper, extendParams, on, emit }) {

let nextEl = getEl(params.nextEl);
let prevEl = getEl(params.prevEl);

Object.assign(swiper.navigation, {
nextEl,
prevEl,
});
return;
nextEl = makeElementsArray(nextEl);
prevEl = makeElementsArray(prevEl);

Expand Down

0 comments on commit aac2dcf

Please sign in to comment.