Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/blue-frogs-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@stratakit/mui": patch
---

Fixed an issue where the viewport was still scrollable when a `Dialog` or `Drawer` was open.
1 change: 1 addition & 0 deletions packages/mui/src/~components.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
@import "./~components/MuiCard.css";
@import "./~components/MuiCheckbox.css";
@import "./~components/MuiChip.css";
@import "./~components/MuiDrawer.css";
@import "./~components/MuiDialog.css";
@import "./~components/MuiDivider.css";
@import "./~components/MuiForm.css";
Expand Down
8 changes: 8 additions & 0 deletions packages/mui/src/~components/MuiDialog.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/

/**
* Prevents the viewport from scrolling when a Dialog is open.
* This is necessary because the equivalent JS doesn't work when Dialog is rendered in a portal container.
*/
:is(html, body):where(:has(.MuiDialog-root:not(.MuiModal-root.MuiModal-hidden))) {
overflow: clip;
}

.MuiDialog-paper {
--✨min-inset: var(--stratakit-space-x4);

Expand Down
12 changes: 12 additions & 0 deletions packages/mui/src/~components/MuiDrawer.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/

/**
* Prevents the viewport from scrolling when a Drawer is open.
* This is necessary because the equivalent JS doesn't work when Drawer is rendered in a portal container.
*/
:is(html, body):where(:has(.MuiDrawer-root:not(.MuiModal-root.MuiModal-hidden))) {
overflow: clip;
}
14 changes: 12 additions & 2 deletions packages/mui/src/~createTheme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,12 @@ function createTheme(args: CreateThemeArgs) {
},
},
MuiContainer: { defaultProps: { component: Role.div } },
MuiDialog: { defaultProps: { component: Role.div } },
MuiDialog: {
defaultProps: {
component: Role.div,
disableScrollLock: true, // Handled in MuiDialog.css instead.
},
},
MuiDialogContentText: {
defaultProps: {
component: Role.p,
Expand All @@ -349,7 +354,12 @@ function createTheme(args: CreateThemeArgs) {
},
},
MuiDivider: { defaultProps: { component: MuiDivider } },
MuiDrawer: { defaultProps: { component: Role.div } },
MuiDrawer: {
defaultProps: {
component: Role.div,
disableScrollLock: true, // Handled in MuiDrawer.css instead.
},
},
MuiFab: {
defaultProps: {
component: MuiButtonBase,
Expand Down
Loading