Fix carousel navigating in wrong direction on first arrow click - #54
Open
AkshitaSharma211 wants to merge 1 commit into
Open
Fix carousel navigating in wrong direction on first arrow click#54AkshitaSharma211 wants to merge 1 commit into
AkshitaSharma211 wants to merge 1 commit into
Conversation
Root cause: react-responsive-carousel's internal index tracking becomes unreliable when centerMode and infiniteLoop are used together, causing the first click on the next arrow to navigate in the wrong direction. Fix: manage the current slide index manually via component state instead of relying on the library's internal tracking, using selectedItem/onChange for controlled navigation and custom arrow renderers that call our own index logic. Fixes #4450
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes the carousel navigation bug reported in #4450, where clicking the right arrow on the "Used by Scientific Leaders" carousel would first navigate left before correctly navigating right on the second click.
Root cause
react-responsive-carousel's internal index tracking becomes unreliable when centerMode and infiniteLoop are used together, causing the first click on the next arrow to navigate in the wrong direction.
Fix
Manage the current slide index manually via component state instead of relying on the library's internal tracking, using selectedItem/onChange for controlled navigation and custom arrow renderers that call our own index logic.
Testing
Fixes #4450