I have a modal that pops up on my website when a user clicks a button. However, when the modal is open, the user can still scroll the page behind it, which is causing issues with the layout and user experience. I want to prevent scrolling when the modal is open, but allow scrolling when the modal is closed.
I've tried adding overflow: hidden to the body element, but this prevents scrolling even when the modal is closed. Is there a way to disable scrolling only when the modal is open, and re-enable scrolling when the modal is closed? Any help or suggestions would be appreciated.