materialize
materialize copied to clipboard
Can't scroll after close modal
I'm using version 1.0.0 latest release and have a problem with modals
When the modal is open, <body style="overflow: hidden;">
this css is added to body tag, but it's not removed when I'm closing the modal, so I'm not able to scroll the website then..
The issue is visible on desktop version of Chrome, Firefox, and also mobile (android), I didn't notice the issue on iOS devices.
Can you provide a codepen so we can reproduce this?
The same happens to me.
The problem is when the modal's close method run, the attr isOpen is always false, then the function returns and not follows to the next condition to changes body's style. I solved this adding document.body.style.overflow = '' before return ''' /** * Close Modal */
}, {
key: "close",
value: function close() {
if (!this.isOpen) { //<========= here isOpen is always false
document.body.style.overflow = ''; // I added this line
return;
}
'''
This workaround fixed it for me:
const options = {
onCloseEnd() {
$('body').css('overflow', '')
}
}
M.Modal.init(elem, options)
I can't reproduce this locally. Please submit a codepen that reproduces this issue
I'll try to get a codepen up by this weekend.
having this problem in 2023