Skip to content
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

Closed
fltonii opened this issue Dec 17, 2018 · 7 comments · Fixed by #16850
Closed

[Modal] Implement disableScrollLock property #13922

fltonii opened this issue Dec 17, 2018 · 7 comments · Fixed by #16850
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

@fltonii
Copy link

fltonii commented Dec 17, 2018

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.

@oliviertassinari

This comment has been minimized.

@oliviertassinari oliviertassinari added the component: modal This is the name of the generic UI component, not the React module! label Dec 17, 2018
@jeffshaver

This comment has been minimized.

@oliviertassinari

This comment has been minimized.

@oliviertassinari oliviertassinari added the new feature New feature or request label Jan 27, 2019
@oliviertassinari oliviertassinari changed the title Modal Manager [Modal] Implement disableScrolLock property Jan 27, 2019
@oliviertassinari
Copy link
Member

We could add a property for this.

@jeffshaver

This comment has been minimized.

@oliviertassinari oliviertassinari added the priority: important This change can make a difference label Mar 13, 2019
@oliviertassinari oliviertassinari changed the title [Modal] Implement disableScrolLock property [Modal] Implement disableScrollLock property Mar 13, 2019
@Sojborg
Copy link

Sojborg commented Mar 20, 2019

I also need to be able to disableScrollLock. Sounds good with a property for this.

@oliviertassinari
Copy link
Member

@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);
       }

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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants