Skip to content

refactor(Collapse)!: drop the toggle option - #709

Closed
mrholek wants to merge 3 commits into
feat/promise-lifecycle-api-v6from
refactor/collapse-drop-toggle-option-v6
Closed

refactor(Collapse)!: drop the toggle option#709
mrholek wants to merge 3 commits into
feat/promise-lifecycle-api-v6from
refactor/collapse-drop-toggle-option-v6

Conversation

@mrholek

@mrholek mrholek commented Aug 7, 2026

Copy link
Copy Markdown
Member

Stacked on #708 (which is stacked on #707). Merge those first; I will retarget this at v6-dev afterwards.

The toggle option made the constructor change the state the markup declares. That surprised people, so almost every caller passed toggle: false — including our own data API handler, the accordion's _getFirstLevelChildren wiring, the jQuery bridge, and 15 call sites in our own spec.

The constructor now always keeps the declared state:

- const collapse = new coreui.Collapse('#myCollapse', { toggle: false })
+ const collapse = new coreui.Collapse('#myCollapse')
+ collapse.show()

data-coreui-toggle="collapse" on a trigger is a different thing and is unchanged.

Removing it also deletes the _configAfterMerge string coercion (config.toggle = Boolean(config.toggle)) and empties the jQuery interface's _config juggling, which existed only to pass toggle: false for show/hide.

Tests

should not change tab tabpanels descendants on accordion needed 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 calling show(). 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 explicit hide(), as upstream did. The getOrCreateInstance specs asserted on _config.toggle; they assert on _config.parent instead.

Collapse suite: 43 specs, green.

Ported from twbs/bootstrap#42799.

mrholek added 3 commits August 7, 2026 16:33
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
mrholek force-pushed the feat/promise-lifecycle-api-v6 branch from 8311719 to ab8992e Compare August 7, 2026 15:07
@mrholek
mrholek deleted the branch feat/promise-lifecycle-api-v6 August 7, 2026 15:07
@mrholek mrholek closed this Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant