From 4d7732083bcb0bd46893cf2e6711715d1645db56 Mon Sep 17 00:00:00 2001 From: Alquen Sarmiento Date: Thu, 14 May 2026 10:19:04 +0800 Subject: [PATCH] fix: clamp the current slide to the slide range --- src/block/carousel/frontend-carousel.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/block/carousel/frontend-carousel.js b/src/block/carousel/frontend-carousel.js index f84bacc5c..abc2d65be 100644 --- a/src/block/carousel/frontend-carousel.js +++ b/src/block/carousel/frontend-carousel.js @@ -677,8 +677,9 @@ class _StackableCarousel { return result }, { slide: 1, offsetDiff: 1000 } ) - if ( this.infiniteScroll && slide > this.slideEls.length ) { - slide -= this.slideEls.length + if ( this.infiniteScroll ) { + // Clamp clone indexes back to the original slide range. + slide = ( ( slide - 1 ) % this.slideEls.length ) + 1 } this.currentSlide = slide