If the buttons where in phaser too, you could simply use this.input.setTopOnly(true).
In my example I use a popup. I could solve it either by stealing the pointer events or disable the inputs in phaser completely while the popup is shown. But, since your buttons are always visible, both of these solutions would not work.
I came up with a temporary fix like this. It will disable the input if you hit a child element of the react div, but not the div itself. But it works only after on additional click event
react.addEventListener('click', e => {
this.input.enabled = e.composedPath()[0].id === 'react'
})
Woow! Thanks a lot @samme . Finally I got it to work!
This is what I’ve changed on line #80 in mainScene.tsx
let reactDiv = document.getElementById('react')
if (!reactDiv) throw new Error('#react not found')
reactDiv.addEventListener('mousedown', (event: Event) => {
// if the click is not on the root react div, we call stopPropagation()
let target = event.target as HTMLElement
if (target.id !== 'react') event.stopPropagation()
})
let react = this.add.dom(0, 0, reactDiv)