fix Dialog and Drawer scroll lock - #1668
Conversation
32aa79f to
605aad6
Compare
|
Looking into handling this more generally for |
There was a problem hiding this comment.
Tested:
- macOS Safari
- macOS Chrome
- Used dev tools to make the dialog's body text introduce a scroll bar.

- Did not test with
scroll="body"MUIDialogprop as I'm seeing it's proposed to be deprecated.
- Used dev tools to make the dialog's body text introduce a scroll bar.
- iOS Safari
- Noticed the address bar still resizes on upwards scroll but I don't think we have any control over that. https://github.com/user-attachments/assets/229d447e-3ed5-4c5d-9170-f18d25a05c68
605aad6 to
17e7ea7
Compare
I've looked into this and found it difficult to handle in a more general way. There is no reliable selector that I can use. I would have liked to target a custom class which is conditionally set based on the In the end, I decided to simply duplicate the CSS for |
17e7ea7 to
b4078be
Compare
@FlyersPh9 This is a very interesting finding, thanks for testing. I think the "modern" way to solve this is by using Once this becomes widely available, we might be able to replace the current implementation with this: .MuiModal-root {
overflow: hidden;
overscroll-behavior: contain;
} |
Changes
This fixes #1656 by adding CSS
overflow: clipto the<html>and<body>elements when aDialogorDraweris open. This is done using a compound:hasselector, similar to one used in~reset.css.Normally, this would be handled by the
ModalJS. However, as pointed out in #1656 (comment), the scroll container is calculated incorrectly when thecontainerprop is set. To prevent a strayoverflow: hiddenfrom being added to the portal container, I've setdisableScrollLocktotrue(for bothDialogandDrawer).Notes
Modalbased on the value ofdisableScrollLock, but couldn't find a way. See comment.overflow: clip. See comment 1 and comment 2.Testing
Confirmed that the page is not scrollable when a
DialogorDraweris open.Also tested that scroll is not over-aggressively blocked when using
keepMountedorscroll="body"props onDialog.Deploy preview