Skip to content

Allow keyed components to share an element - #42992

Merged
mdo merged 2 commits into
mainfrom
mdo/data-multiple-instances
Nov 4, 2026
Merged

mdo merged 2 commits into
mainfrom
mdo/data-multiple-instances

Conversation

@mdo

@mdo mdo commented Oct 7, 2026

Copy link
Copy Markdown
Member

What changed

  • Remove the Data.set() guard that rejected a second component key on the same element.
  • Remove the insertion-order-dependent Data.getAny() helper.
  • Look up tooltip, popover, and toast instances by their explicit keys when a dialog or drawer closes.
  • Cover keyed coexistence, independent disposal, Combobox/Menu registration and reuse, and overlay cleanup regardless of registration order.

Combobox intentionally composes a Menu on its toggle. Previously, bs.combobox registered first and the bs.menu registration failed. The Menu object still finished construction, but Menu.getOrCreateInstance() could not find it and created more unregistered Menu instances during keyboard handling.

Same-component replacement remains unchanged: constructing another instance with the same key still disposes the previous instance first.

Closes #42965

Tests

  • npm run js-test — 1,356 tests passed, including bundle and modularity integration builds
  • npm run js-typecheck
  • ESLint on changed files

@mdo
mdo requested a review from a team as a code owner October 7, 2026 03:54
@mdo mdo added js JavaScript or TypeScript sources and plugins v6 v6, the main branch labels Oct 7, 2026
@mdo mdo added this to v6.0.0 Oct 7, 2026
@julien-deramond julien-deramond added the bug Something does not work as documented label Oct 10, 2026
mdo added 2 commits November 4, 2026 09:42
Combobox creates a Menu on its toggle, but the Data guard rejects the
second component key. The Menu remains unregistered, so keyboard handling
creates additional instances and logs an error on every interaction.

Allow differently keyed instances to coexist while preserving same-key
replacement and independent disposal. Replace the ambiguous getAny lookup
in dialog cleanup with explicit component keys so overlays are hidden
regardless of registration order.
Add an alpha 2 section to the migration guide. Explain keyed instance
lookup, same-type replacement, and removal of the internal getAny helper.
Document that Combobox owns the Menu registered on its toggle.
@mdo
mdo force-pushed the mdo/data-multiple-instances branch from 9d1451d to 6aba5a4 Compare November 4, 2026 17:45
@mdo
mdo merged commit 3fc7f7d into main Nov 4, 2026
15 checks passed
@mdo
mdo deleted the mdo/data-multiple-instances branch November 4, 2026 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something does not work as documented js JavaScript or TypeScript sources and plugins v6 v6, the main branch

Projects

Status: Inbox

Development

Successfully merging this pull request may close these issues.

v6: Combobox logs "Bootstrap doesn't allow more than one instance per element. Bound instance: bs.combobox."

2 participants