Skip to content

Commit ddedc56

Browse files
author
Andreas Heim
committed
[Popover/Modal] Prevent page scroll on open when html overflow is not applied
1 parent 9c2f734 commit ddedc56

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/material-ui/src/Modal/ModalManager.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ function handleContainer(containerInfo, props) {
6464
// Improve Gatsby support
6565
// https://css-tricks.com/snippets/css/force-vertical-scrollbar/
6666
const parent = container.parentElement;
67-
const scrollContainer = parent.nodeName === 'HTML' ? parent : container;
67+
const scrollContainer =
68+
parent.nodeName === 'HTML' && window.getComputedStyle(parent)['overflow-y'] === 'scroll'
69+
? parent
70+
: container;
6871

6972
restoreStyle.push({
7073
value: scrollContainer.style.overflow,

0 commit comments

Comments
 (0)