docs: clarify carousel getInstance timing and pause in events#42358
Open
pierluigilenoci wants to merge 1 commit intotwbs:mainfrom
Open
docs: clarify carousel getInstance timing and pause in events#42358pierluigilenoci wants to merge 1 commit intotwbs:mainfrom
pierluigilenoci wants to merge 1 commit intotwbs:mainfrom
Conversation
Add two warning callouts to the carousel documentation: - In "Via JavaScript": document that `Carousel.getInstance` returns `null` for uninitialized carousels and recommend `getOrCreateInstance` or the `window` `load` event as alternatives. - In "Events": clarify that calling `pause` inside a `slide.bs.carousel` handler has no effect and recommend using `slid.bs.carousel` instead. Fixes twbs#35722 Signed-off-by: Pierluigi Lenoci <pierluigilenoci@gmail.com>
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
Add two warning callouts to the carousel documentation addressing the pain points reported in #35722:
"Via JavaScript" section: Document that
Carousel.getInstance()returnsnullfor uninitialized carousels. RecommendgetOrCreateInstance()(preferred) or deferring code until thewindowloadevent as alternatives."Events" section: Clarify that calling
pause()inside aslide.bs.carouselhandler has no effect because the slide transition is already in progress, and recommend usingslid.bs.carouselinstead.Motivation & Context
Issue #35722 reports that developers frequently struggle with
getInstance()returningnulland withpause()not working insideslideevents. Two previous PRs (#37062, #38619) attempted to fix this but were closed — one had extraneous formatting changes, the other referenced jQuery which Bootstrap 5 no longer depends on. This PR uses only vanilla JavaScript and makes minimal, targeted additions.Type of changes
Checklist
Related issues
Fixes #35722