i have this delete-popup div
<div class="delete-popup">
<div class="popup-icon-box">
<img src="icon/delete-icon.svg" alt="delete-icon" class="popup-icon" />
</div>
<h4 class="heading">Kamu yakin ingin menghapus?</h4>
<p class="popup-text">Setiap buku yang telah dihapus tidak dapat dikembalikan lagi</p>
<div class="popup-confirmation-button">
<button class="btn btn--outline no-opacity">Cancel</button>
<button class="btn btn--red">Delete</button>
</div>
</div>
and this is the event delegation i attach to the document
document.addEventListener("click", function (e) {
if (isPopupShowed) {
if (!e.target.classList.contains("delete-popup")) {
deletePopup.classList.remove("show-popup");
deletePopup.classList.add("close-popup");
isPopupShowed = false;
deletePopup.addEventListener("animationend", function () {
deletePopup.classList.remove("close-popup");
});
}
}
if (e.target.classList.contains("delete")) {
deletePopup.classList.add("show-popup");
isPopupShowed = true;
}
});
inside if(isPopupShowed) i check if user click outside the popup container then the popup will close however if i click element inside the container itself(e.g heading/icon/etc) it will also close the popup container. How do i prevent this from happening? i tried to use stopPropagation but it doesn't seem to work.