Skip to content

fix(js): recognize modern DOM events in EventHandler nativeEvents set - #43293

Open
ShakilUrRehman21 wants to merge 1 commit into
twbs:mainfrom
ShakilUrRehman21:fix/event-handler-native-events-list
Open

ShakilUrRehman21 wants to merge 1 commit into
twbs:mainfrom
ShakilUrRehman21:fix/event-handler-native-events-list

Conversation

@ShakilUrRehman21

Copy link
Copy Markdown
Contributor

Description

In js/src/dom/event-handler.ts, normalizeParameters() checks nativeEvents.has(typeEvent) to distinguish native DOM events from custom events. If an event is not in nativeEvents, it retains the dot namespace in the event type:

if (!nativeEvents.has(typeEvent)) {
  typeEvent = originalTypeEvent // e.g. 'cancel.bs.dialog'
}
element.addEventListener(typeEvent, fn)

Because browsers do not recognize namespaced event names, registering namespaced listeners for valid modern DOM events (such as cancel.bs.dialog, beforeinput.bs.otp, or toggle.bs.popover) causes the listener to fail silently and never execute.

This PR adds standard modern DOM events to nativeEvents:

  • beforeinput (used by OTP input and rich text controls)
  • cancel and close (HTML5 <dialog> and <form method="dialog">)
  • toggle (HTML5 <details> and Popover API)
  • copy and cut (Clipboard API)
  • drag, dragstart, dragend, dragenter, dragleave, dragover, drop (Drag and Drop API)
  • selectionchange (Selection API)

Motivation and context

Ensures standard modern native DOM events can be namespaced and managed through Bootstrap's EventHandler utility.

Type of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I have read the contributing guide
  • My code follows the code style of this project
  • I have added tests that prove my fix is effective
  • All new and existing unit tests passed
  • Bundle size verified with npm run bundlewatch

@ShakilUrRehman21
ShakilUrRehman21 requested a review from a team as a code owner November 4, 2026 06:04
@julien-deramond julien-deramond added v6 v6, the main branch feature New feature, or a change to how an existing one works js JavaScript or TypeScript sources and plugins tests Unit, visual or CSS tests labels Nov 4, 2026
@netlify

netlify Bot commented Nov 6, 2026

Copy link
Copy Markdown

✅ Deploy Preview for twbs-bootstrap ready!

Name Link
🔨 Latest commit ad3eecc
🔍 Latest deploy log https://app.netlify.com/projects/twbs-bootstrap/deploys/6aed9a4208b5d512d8074dc9
😎 Deploy Preview https://deploy-preview-43293--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.

@julien-deramond julien-deramond added the has-conflicts Conflicts with its base branch: needs a rebase label Nov 12, 2026
@ShakilUrRehman21
ShakilUrRehman21 force-pushed the fix/event-handler-native-events-list branch from 9506305 to 15aaacb Compare November 13, 2026 13:20
@julien-deramond julien-deramond removed the has-conflicts Conflicts with its base branch: needs a rebase label Nov 13, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature, or a change to how an existing one works js JavaScript or TypeScript sources and plugins tests Unit, visual or CSS tests v6 v6, the main branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants