button click inside CSUI closes the CSUI

When I click on a button inside the injected CSUI, the whole component is closing. I am using a useeffect with an event listener for mouseup event. However when I add the event listener to document.body instead of document, it works properly. But the problem is I can't add some event listeners to document body. Did anyone face this issue before?