From 900e047b637d8dec2c1908f41571af6a47572a47 Mon Sep 17 00:00:00 2001 From: Galpittel <95571398+Galpittel@users.noreply.github.com> Date: Thu, 11 Jul 2024 09:50:55 +0300 Subject: [PATCH] change invalid activeIndex when the number of items in the gallery is smaller than the current activeIndex (#1259) --- .../components/gallery/proGallery/slideshowView.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/gallery/src/components/gallery/proGallery/slideshowView.js b/packages/gallery/src/components/gallery/proGallery/slideshowView.js index 41be7fa93..10c9bf5d6 100644 --- a/packages/gallery/src/components/gallery/proGallery/slideshowView.js +++ b/packages/gallery/src/components/gallery/proGallery/slideshowView.js @@ -1168,6 +1168,18 @@ class SlideshowView extends React.Component { this.startAutoSlideshowIfNeeded(props.options); }); } + if (this.state.activeIndex > props.items.length - 1) { + utils.setStateAndLog( + this, + 'Next Item', + { + activeIndex: 0, + }, + () => { + this.onCurrentItemChanged(); + } + ); + } if (this.props.activeIndex !== props.activeIndex) { utils.setStateAndLog( this,