For those developing for the web, the solution would be to use event.stopPropagation(). It stops clicks for the parent not to trigger the child and vice versa
https://developer.mozilla.org/en-US/docs/Web/API/Event/stopPropagation