Repository navigation
Carousel: make the left arrow go to the next slide in RTL - #43264
Merged
Merged
Conversation
In RTL the slides run right to left, so the next slide is on the left. The keydown handler always sent ArrowLeft to prev() and ArrowRight to next(). In RTL the arrow keys moved the carousel the wrong way. With `ends: 'stop'`, ArrowLeft did nothing on the first slide. Bootstrap 5 mirrored the arrow keys in RTL. The scroll-snap rebuild dropped that step. Mirror the keys again, the same way `_direction()` already mirrors the event direction. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Use the document direction to pick the key for the next slide. Check the active slide in both directions with wrapping disabled.
✅ Deploy Preview for twbs-bootstrap ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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
ArrowLefttoprev()andArrowRighttonext(), so in RTL the arrow keys moved the carousel the wrong way. Withends: 'stop',ArrowLeftdid nothing on the first slide._direction()already mirrors the event direction.js/tests/unit/carousel.spec.jssetsdir="rtl"and checks thatArrowLeftcallsnext()andArrowRightcallsprev(). It fails before the change (expected "next" to be called 1 times, but got 0 times) and passes after it (102 tests in the carousel spec).Motivation & Context
mainthe carousel goes the other way.Type of changes
Checklist
npm run lint)ESLint reports no errors on the changed files; the new test takes
carousel.spec.jsto 1512 lines, so it now trips themax-lineswarning (limit 1500). Happy to move the test or split the file if you prefer.Live previews
Related issues
I used Claude Code to write this change.