From c0f7bb6f3612f42664eab60bbcfb7969bfeb16bf Mon Sep 17 00:00:00 2001 From: Vladimir Kharlampidi Date: Thu, 30 May 2024 12:33:10 +0300 Subject: [PATCH] fix(navigation): prevent hide on click when clicking on navigation buttons fixes #7559 --- src/modules/navigation/navigation.mjs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/modules/navigation/navigation.mjs b/src/modules/navigation/navigation.mjs index a00854b47..4458722b0 100644 --- a/src/modules/navigation/navigation.mjs +++ b/src/modules/navigation/navigation.mjs @@ -161,11 +161,15 @@ export default function Navigation({ swiper, extendParams, on, emit }) { nextEl = makeElementsArray(nextEl); prevEl = makeElementsArray(prevEl); const targetEl = e.target; - if ( - swiper.params.navigation.hideOnClick && - !prevEl.includes(targetEl) && - !nextEl.includes(targetEl) - ) { + let targetIsButton = prevEl.includes(targetEl) || nextEl.includes(targetEl); + + if (swiper.isElement && !targetIsButton) { + const path = e.path || (e.composedPath && e.composedPath()); + if (path) { + targetIsButton = path.find((pathEl) => nextEl.includes(pathEl) || prevEl.includes(pathEl)); + } + } + if (swiper.params.navigation.hideOnClick && !targetIsButton) { if ( swiper.pagination && swiper.params.pagination &&