Overall what I am doing is I have a datepicker where clicks bubble up to the body, and I also have ag-grid which has a column menu that listens for clicks on the body and closes the menu. See plunkr, just have to click the hamburger next to DOB and go to filters, then click the datepicker and pick a date. notice the menu doesn't close. It stays open because of the event listener added in the app.component which stops the event from propagating to the grid once it hits the body. Everything works as I understand it should.
https://plnkr.co/edit/QDUVOUEHJYMNSumVFICc?p=preview
document.body.addEventListener('click', event => {
if (~event.srcElement.outerHTML.indexOf('mat-calendar-body')) {
event.preventDefault();
event.stopPropagation();
event.stopImmediatePropagation();
}
});
The issue I am having is that the exact same setup in my app doesn't work. The event handlers are called, and in the correct order, but for some reason in my app even after cancelling the event using the same handler, the grid still gets the event and closes the menu. What I am looking for here is some ideas for what could cause the behavior I am seeing. Obviously I would setup a plunkr to demonstrate, but I can't because it seems to work three and I can upload my entire app.