refactor(Collapse)!: drop the toggle option - #709
Closed
mrholek wants to merge 3 commits into
Closed
Conversation
Toast was the last component driving its animation from JavaScript: it toggled `.fade`, forced a reflow, then juggled `.show`, `.showing` and a deprecated `.hide` class to fake an exit animation. Menu and the picker popup already express this in CSS, so Toast now does the same — `@starting-style` supplies the state to animate from, and a discrete `display` transition keeps the toast laid out until the fade-out finishes. JavaScript only toggles `.show`. BREAKING CHANGE: the `animation` option and `data-coreui-animation` are gone; add `.toast-instant` to skip the animation. The `.showing` class and the deprecated `.hide` class are gone with them, and toasts no longer take the generic `.fade` class. `isShown()` now returns `false` as soon as `hide()` is called, rather than when the fade-out ends. Ported from twbs/bootstrap#42783.
`show()`, `hide()`, `toggle()` and `close()` returned before the transition ended, so a caller had to listen for a `shown.coreui.*` or `hidden.coreui.*` event to continue. `_queueCallback` now returns a promise and each component awaits it, so a caller can `await` the method instead. The promise always settles, so a no-op call — already open, a prevented `show.coreui.*`, an instance disposed mid-transition — cannot strand the caller. That last case also needed the completion callback to be skipped once the instance is gone, which `_queueCallback` now does. Covered by Collapse, Menu, Modal, Offcanvas, Popover, Sidebar and Tooltip (`show`/`hide`/`toggle`), Toast (`show`/`hide`), Tab (`show`) and Alert (`close`). Carousel keeps its own cue-based API. The event path is unchanged. Ported from twbs/bootstrap#42802, adapted to the components this tree has.
The `toggle` option made the constructor change the state that the markup
declares. That surprised people, so almost every caller passed
`toggle: false` — including our own data API, our accordion wiring and the
jQuery bridge.
The constructor now always keeps the declared state. Add `.show` to start
open, and call `show()`, `hide()` or `toggle()` to change it.
BREAKING CHANGE: `toggle` is no longer a Collapse option. Replace
`new Collapse(el, { toggle: false })` with `new Collapse(el)`, and a caller
that relied on the constructor toggling with `new Collapse(el).toggle()`.
`data-coreui-toggle` on a trigger is unrelated and unchanged.
Ported from twbs/bootstrap#42799.
mrholek
force-pushed
the
feat/promise-lifecycle-api-v6
branch
from
August 7, 2026 15:07
8311719 to
ab8992e
Compare
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.
The
toggleoption made the constructor change the state the markup declares. That surprised people, so almost every caller passedtoggle: false— including our own data API handler, the accordion's_getFirstLevelChildrenwiring, the jQuery bridge, and 15 call sites in our own spec.The constructor now always keeps the declared state:
data-coreui-toggle="collapse"on a trigger is a different thing and is unchanged.Removing it also deletes the
_configAfterMergestring coercion (config.toggle = Boolean(config.toggle)) and empties the jQuery interface's_configjuggling, which existed only to passtoggle: falseforshow/hide.Tests
should not change tab tabpanels descendants on accordionneeded a real fix rather than a find-and-replace: its element starts.show, and it relied on the constructor's auto-toggle to close it before callingshow(). Without that,show()is a no-op on an already-open element and the hide/show cycle never starts (the spec times out — confirmed before fixing). It now starts the cycle with an explicithide(), as upstream did. ThegetOrCreateInstancespecs asserted on_config.toggle; they assert on_config.parentinstead.Collapse suite: 43 specs, green.
Ported from twbs/bootstrap#42799.