I identified two key issues in my previous tests:
stopPropagation()
instead of stopImmediatePropagation()
- the latter prevents all subsequent handlers from executingHere's the working solution (must be placed before Bootstrap import):
document.addEventListener('click', (event) => {
if(event.target.nodeName === 'CANVAS') {
event.stopImmediatePropagation();
}
}, true);
import('bootstrap/dist/js/bootstrap.min.js');
Although effective, this workaround has limitations:
This approach blocks all click events on canvas elements, affecting both Phaser and Google Tag Manager. In my case, this wasn't problematic since I'm using mouseup/mousedown events in Phaser rather than click events.
If you need click event functionality, you can follow @C3roe's suggestion to stop and then manually re-propagate the event to specific handlers.
An official Bootstrap method to exclude specific DOM elements from event handling would be preferable.