-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Modal] Implement disableScrollLock property #13922
Labels
component: modal
This is the name of the generic UI component, not the React module!
good first issue
Great for first contributions. Enable to learn the contribution process.
new feature
New feature or request
priority: important
This change can make a difference
Comments
This comment has been minimized.
This comment has been minimized.
1 task
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
We could add a property for this. |
This comment has been minimized.
This comment has been minimized.
1 task
I also need to be able to disableScrollLock. Sounds good with a property for this. |
@Sojborg If you want to give it a shot, it shouldn't be harder than: --- a/packages/material-ui/src/Modal/Modal.js
+++ b/packages/material-ui/src/Modal/Modal.js
@@ -213,6 +213,7 @@ class Modal extends React.Component {
disableEscapeKeyDown,
disablePortal,
disableRestoreFocus,
+ disableScrollLock,
hideBackdrop,
innerRef,
keepMounted,
@@ -354,6 +355,10 @@ Modal.propTypes = {
*/
disableRestoreFocus: PropTypes.bool,
/**
+ * Disable the scroll lock behavior.
+ */
+ disableScrollLock: PropTypes.bool,
+ /**
* If `true`, the backdrop is not rendered.
*/
hideBackdrop: PropTypes.bool,
@@ -412,6 +417,7 @@ Modal.defaultProps = {
disableEscapeKeyDown: false,
disablePortal: false,
disableRestoreFocus: false,
+ disableScrollLock: false,
hideBackdrop: false,
keepMounted: false,
// Modals don't open on the server so this won't conflict with concurrent requests.
diff --git a/packages/material-ui/src/Modal/ModalManager.js b/packages/material-ui/src/Modal/ModalManager.js
index 0a381abb9..f6334de0e 100644
--- a/packages/material-ui/src/Modal/ModalManager.js
+++ b/packages/material-ui/src/Modal/ModalManager.js
@@ -75,10 +75,9 @@ function removeContainerStyle(data) {
*/
class ModalManager {
constructor(options = {}) {
- const { hideSiblingNodes = true, handleContainerOverflow = true } = options;
+ const { hideSiblingNodes = true } = options;
this.hideSiblingNodes = hideSiblingNodes;
- this.handleContainerOverflow = handleContainerOverflow;
// this.modals[modalIdx] = modal
this.modals = [];
@@ -130,7 +129,7 @@ class ModalManager {
const containerIdx = findIndexOf(this.data, item => item.modals.indexOf(modal) !== -1);
const data = this.data[containerIdx];
- if (!data.style && this.handleContainerOverflow) {
+ if (!data.style && !modal.props.disableScrollLock) {
setContainerStyle(data);
}
}
@@ -150,7 +149,7 @@ class ModalManager {
// If that was the last modal in a container, clean up the container.
if (data.modals.length === 0) {
- if (this.handleContainerOverflow) {
+ if (!data.style && !modal.props.disableScrollLock) {
removeContainerStyle(data);
} |
1 task
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
component: modal
This is the name of the generic UI component, not the React module!
good first issue
Great for first contributions. Enable to learn the contribution process.
new feature
New feature or request
priority: important
This change can make a difference
Is there any documentation regarding this functionality out there? I saw a mention of it in the modal api reference but can't find when/how to use it.
The text was updated successfully, but these errors were encountered: