Skip to content

Commit c0f7bb6

Browse files
committed
fix(navigation): prevent hide on click when clicking on navigation buttons
fixes #7559
1 parent 39a3e53 commit c0f7bb6

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/modules/navigation/navigation.mjs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,15 @@ export default function Navigation({ swiper, extendParams, on, emit }) {
161161
nextEl = makeElementsArray(nextEl);
162162
prevEl = makeElementsArray(prevEl);
163163
const targetEl = e.target;
164-
if (
165-
swiper.params.navigation.hideOnClick &&
166-
!prevEl.includes(targetEl) &&
167-
!nextEl.includes(targetEl)
168-
) {
164+
let targetIsButton = prevEl.includes(targetEl) || nextEl.includes(targetEl);
165+
166+
if (swiper.isElement && !targetIsButton) {
167+
const path = e.path || (e.composedPath && e.composedPath());
168+
if (path) {
169+
targetIsButton = path.find((pathEl) => nextEl.includes(pathEl) || prevEl.includes(pathEl));
170+
}
171+
}
172+
if (swiper.params.navigation.hideOnClick && !targetIsButton) {
169173
if (
170174
swiper.pagination &&
171175
swiper.params.pagination &&

0 commit comments

Comments
 (0)