imagine10255/bear-react-carousel

bug: activePage is greater than total when using more than 1 slidesPerView with isEnableLoop={true} and going to the borders

Closed this issue · 1 comments

Describe the bug
ActivePage is greater than the total number of pages and the page indicator shows as empty
image

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://bear-react-carousel.pages.dev/docs/props-try
  2. Click the left arrow or swipe (because if you don't go to the left, the right arrow will never show, i guess that's another bug)
  3. Disable auto mode
  4. Set slides per view to 2
  5. Click the right arrow 2 times (or swipe to the left 2 times)
  6. See error
    image
    image

Expected behavior
Everything should work and the indicator should indicate the current page and not empty

(Btw, awesome library! keep up the good work)

@tnfAngel
Hi, I found that the issue reoccurs when props change, causing problems with manipulating the DOM to set the active state. I've adjusted the logic to use this._stater, which seems to resolve the issue and prevents incorrect element attribute judgments due to timing discrepancies. It appears to be functioning correctly now.

However, I haven't been able to identify the root cause of the problem occurring when props change.

Error reproduction prior to version 4.0.27-alpha.0:
Setting isEnableLoop: true by default, then changing it tofalse and using navigation to switch to the last page.

You can try version 4.0.27-alpha.5 to see if the issue persists. The latest updates are also available at https://bear-react-carousel.pages.dev/.

Thank you for bringing this issue to our attention.