question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiple modals scrolling bug

See original GitHub issue

dimmable dimmed are deleted from body when the second modal is closed

Steps

  1. Scroll modal
  2. Open second modal
  3. Scroll modal
  4. Close second modal
  5. Try to scroll modal

Expected Result

The first modal should be scrollable <body class="dimmable dimmed scrolling">

Actual Result

First Modal is not longer scrollabel <body class="scrolling">

Version

tested in 0.64.0 & 0.63.5

Testcase

https://codepen.io/csxmedia/full/mRVgYX/

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:16
  • Comments:16 (7 by maintainers)

github_iconTop GitHub Comments

7reactions
marcdiboldcommented, Jul 7, 2017

my temporary fix

class ModalTrigger extends React.Component {
  constructor(props) { ... }

  componentWillUpdate() {
    this.fixBody();
  }

  componentDidUpdate() {
    this.fixBody();
  }

  fixBody() {
    const anotherModal = document.getElementsByClassName('ui page modals').length;
    if (anotherModal > 0) document.body.classList.add('scrolling', 'dimmable', 'dimmed');
  }

  render() {
    return (
      <Modal ... >
        ...
      </Modal>
    );
  }
}
5reactions
levithomasoncommented, Jan 16, 2017

Yep, this makes sense. I think it is time to consider a stack for managing things like overlays and document level keybindings.

Another example of this issue is pressing ESC. This will close all Dropdowns, Popups, Modals, and anything else that has a document level listener for ESC. Ideally, we’d have a stack of listeners and only the most recent would be invoked and removed. That way, only the top level component unmounts. This would allow opening/closing a Popup inside of a Modal without also closing the Modal.

The stack could also be used here to keep the classes on the body until there were no more page dimmers in the stack.

@jcarbo / @layershifter have you run into needs that would be well served by a stack or top-level Provider component for managing state such as listeners and multiple Portals?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Scrolling issues with multiple bootstrap modals
I played around with closing the background modal with js first (but that messes up scrolling on the second modal). It appears that...
Read more >
Multiple bootstrap modals scrolling issue. #15992
I have my main page where i already have scrolling. Where i am opening one bootstrap dialogue which is also bigger and the...
Read more >
If multiple modals, scroll lock fails to clear after closing last ...
Problem /Motivation When multiple modals are opened, the body scroll lock JS only removes the scroll lock on the last modal.
Read more >
Stop scrolling background while use multiple modals
Hi everyone, this is my first post about Webflow and I wanted to know if I can stop background from scrolling while a...
Read more >
Quick Fix: Scrolling and Focus when multiple bootstrap ...
Still if you face issue when multiple modals are simultaneously open, adding this would fix: $('.modal').on("hidden.bs.modal", function (e) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found