After implementing a modal that appears upon clicking an element on my webpage, I encountered an issue when trying to close it. I added an event listener to the 'close' link element in the top right corner of the modal with the following code snippet:
document.querySelector('.modal__close').addEventListener('click', () => {
modal.style.display = 'none'
})
While this successfully closes the modal, it also causes the page to abruptly scroll back to the top (I've also noticed it adds a '#' to the end of the URL). This behavior is not desired. How can I make the modal gracefully disappear without affecting the underlying display?