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.

Closing modal doesn't unlock the main body

See original GitHub issue

Issue description

  • components: Modal
  • reactstrap version #5.0.0-alpha3
  • import method npm + import
  • react version #16.0.0
  • bootstrap version #4.0.0-beta

What is happening?

The modal background isn’t clearing to allow access to the main body after closing it.

What should be happening?

Not that…

Steps to reproduce issue

  1. Open a modal.
  2. Close it.

Error message in console

None

Code

https://codepen.io/anon/pen/YEXNMv

There might be something else elsewhere in my code that causes this as well, since that link doesn’t actually have the same issue, but I get no errors so I’m not sure how to quickly narrow it down.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
TheSharpieOnecommented, Nov 16, 2017

I think this is related to an issue where toggling the modal too quickly caused it to get into a bad state. A fix was added in 2cdf225. I am trying to cut a release, but am running into rollup issues. I’ll investigate that when I have time and hopefully get a release out soon for you to test.

0reactions
TheSharpieOnecommented, Feb 8, 2018

Are you using css modules to change the className? Looks like we don’t look for the css module className, only the raw className when removing it: https://github.com/reactstrap/reactstrap/blob/2b71fd633ece693089c35ad32d44df84d5776cb3/src/Modal.js#L158-L160 Really, the mapToCssModules should only be happening for modal-open and not the whole className which came from the body. The same so also happen when we add the class. We should only “translate” modal-open and not the whole className on body as we did set any of the other values so we should not potentially modify them.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Modal Closes, but scroll bar doesn't come back - Stack Overflow
In the code I have the 'onclick' event calling .modal('hide') as well as having: data-dismiss="modal" on the button itself. The ajax call executes...
Read more >
If multiple modals, scroll lock fails to clear after closing last ...
When multiple modals are opened, the body scroll lock JS only removes the scroll lock on the last modal. This is the result...
Read more >
Modal · Bootstrap v4.6
Clicking on the modal “backdrop” will automatically close the modal. Bootstrap only supports one modal window at a time.
Read more >
Prevent Page Scrolling When a Modal is Open | CSS-Tricks
If we know the top of the scroll location and add it to our CSS, then the body will not scroll back to...
Read more >
How to prevent Body from scrolling when a modal is opened ...
Approach: A simple solution to this problem is to set the value of the “overflow” property of the body element to “hidden” whenever...
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