Two event listeners. (One over the other)

I have a modal with a button. On tapping anywhere in the background outside the modal, the modal should close. Also, when you tap the button inside the modal, a different action gets performed. (moving to the next screen)

For the background to look darker when the modal is on screen, there’s a black rectangle of the device’s dimension with low opacity.
Currently, there’s an event listener in this black background rectangle that closes the modal when tapped.
This event still gets triggered when I’m tapping on the modal. Also, when tapping on the button, both the events get triggered.

How do I restrict the event listener to only outside of the modal?
(Both are in different groups)

In your event handling code, return the boolean value true to indicate that you have handled the event. That will stop event propagation.

1 Like

Thanks!
It worked.