Skip to content

Carousel: make the left arrow go to the next slide in RTL - #43264

Merged
mdo merged 2 commits into
twbs:mainfrom
b84330808:fix-carousel-rtl-keyboard
Nov 21, 2026
Merged

mdo merged 2 commits into
twbs:mainfrom
b84330808:fix-carousel-rtl-keyboard

Conversation

@b84330808

Copy link
Copy Markdown
Contributor

Description

  • 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(), so 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. This mirrors the keys again, the same way _direction() already mirrors the event direction.
  • A new test in js/tests/unit/carousel.spec.js sets dir="rtl" and checks that ArrowLeft calls next() and ArrowRight calls prev(). 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

  • RTL users press the arrow key that points at the slide they want. On main the carousel goes the other way.

Type of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (non-breaking change)
  • Breaking change (fix or feature that would change existing functionality)

Checklist

  • I have read the contributing guidelines
  • My code follows the code style of the project (using npm run lint)
  • My change introduces changes to the documentation
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed

ESLint reports no errors on the changed files; the new test takes carousel.spec.js to 1512 lines, so it now trips the max-lines warning (limit 1500). Happy to move the test or split the file if you prefer.

Live previews

  • Not applicable, JavaScript only.

Related issues

  • None found.

I used Claude Code to write this change.

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>
@b84330808
b84330808 requested a review from a team as a code owner November 2, 2026 03:53
@julien-deramond julien-deramond added v6 v6, the main branch accessibility Keyboard, screen readers, contrast, ARIA bug Something does not work as documented js JavaScript or TypeScript sources and plugins regression A bug that did not happen in an earlier release rtl Right-to-left support labels Nov 2, 2026
Use the document direction to pick the key for the next slide.
Check the active slide in both directions with wrapping disabled.
@netlify

netlify Bot commented Nov 21, 2026

Copy link
Copy Markdown

✅ Deploy Preview for twbs-bootstrap ready!

Name Link
🔨 Latest commit b93e8ac
🔍 Latest deploy log https://app.netlify.com/projects/twbs-bootstrap/deploys/6b020c47683df2378db61e19
😎 Deploy Preview https://deploy-preview-43264--twbs-bootstrap.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@mdo
mdo merged commit a221626 into twbs:main Nov 21, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

accessibility Keyboard, screen readers, contrast, ARIA bug Something does not work as documented js JavaScript or TypeScript sources and plugins regression A bug that did not happen in an earlier release rtl Right-to-left support v6 v6, the main branch

Projects

Status: Inbox
Status: Inbox

Development

Successfully merging this pull request may close these issues.

3 participants