Closing modal doesn't unlock the main body
See original GitHub issueIssue 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
- Open a modal.
- 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:
- Created 6 years ago
- Comments:7 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

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.
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
mapToCssModulesshould only be happening formodal-openand not the whole className which came from the body. The same so also happen when we add the class. We should only “translate”modal-openand not the whole className on body as we did set any of the other values so we should not potentially modify them.