swiper
swiper copied to clipboard
Multiple slides per view - Clicking links on mobile (or right click/scroll wheel click on desktop) jumps the clicked element to first position instead of opening the link
Check that this is really a bug
- [X] I confirm
Reproduction link
https://codepen.io/Ionut2022/pen/rNJEOgx
Bug description
In sliders with mutliple elements visible that contain a link, clicking on a slide on a mobile device (simulating touch with browser DevTools also works - refresh page after resizing the window), or right clicking/scroll wheel clicking an slide, jumps the clicked slide to the first position instead of opening the link.
The link opens correctly only when the slider is at the last slide, or clicking the first slide of the current view.
Edit: The problem appeared since version 8.0.0 Version 7.4.1 is the last version that works correctly: https://codepen.io/Ionut2022/pen/ZErdJEb
Expected Behavior
Clicking a slide that contains a link on a mobile device opens the link. On desktop, scroll wheel clicking on a slide with a link, opens the link in new tab.
Actual Behavior
Clicking a slide with a link on a mobile device (other then the first slide in the current view), jumps the clicked slide to the first position and does not open the link. Scroll wheel clicking a slide with a link, does not open the link and jumps the clicked slide to the first position.
Swiper version
8.2.4
Platform/Target and Browser Versions
Android Chrome / Windows Chrome
Validations
- [X] Follow our Code of Conduct
- [X] Read the docs.
- [X] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
- [X] Make sure this is a Swiper issue and not a framework-specific issue
Would you like to open a PR for this bug?
- [x] I'm willing to open a PR
I have been debugging the same thing all morning now.
I have 3 slides in view, without centeredSlides, so the left one is the main one. Clicks on the left one will work (opening a modal). Clicks on slide 2 and 3 will make those slides jump to the left, as the main slide. Even tho slideToClickedSlide={false}
(which i highly assume should stop this).
mouse click sliding also makes the slide jump to position 1 before sliding on mouseUp by the way.
Example: https://build-83da0753-50eb-44a2-b27d-cf1b36db2e7f.gtsb.io/voorraad/nieuw/microcar/2022/m-go-dci/must-sun-stb-5-jaar-garantie/1km/30961127/
Hi everyone, I have the same issue.
+1
add target="_blank" in the inside of your a tag to open a new tab
"or right clicking/scroll wheel clicking an slide, jumps the clicked slide to the first position instead of opening the link."
seems to be related with: https://github.com/nolimits4web/swiper/issues/5625
Thanks @nolimits4web , just tested in and fixes the bug! Much appreciated
This is still an issue on mobile/touch devices in version 8.4.2
I have a solution that mobile touch on ui elements like links or select fields no longer makes the slide jump to first place. Touch events also trigger a focus event. I added a condition to check that the focus event was not triggered by touch. #6139