Issues with Modal scrolling/overflow sizing.
See original GitHub issueHi guys,
I’m having an issue with a simple modal that I am trying to implement in a react/flux project. Here is the code for the Modal component (for testing purposes).
'use strict';
//Library Dependencies
const React = require('react');
const Modal = require('react-modal');
const AmazonModal = React.createClass({
render() {
//Modal Config
const customStyles = {
content : {
top: '50%',
left: '50%',
right: 'auto',
bottom: 'auto',
marginRight: '-50%',
transform: 'translate(-50%, -50%)'
},
overlay: {
zIndex: 10
}
};
return (
<Modal
isOpen = { this.props.modalIsOpen }
onRequestClose = { TBD }
style = { customStyles } >
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
</Modal>
)
},
_closeModal() {
this.props.closeModal();
}
});
module.exports = AmazonModal;
Currently I have two Issues that I cannot solve:
The Modal is rendering but I am unable to see the full content of the modal. I am unable to scroll through the content. When I scroll it simply scrolls through the greyed out content behind it. I tried playing with all overflow settings for the content/overlay…but had no luck getting the desired outcome.
- I would like to be able to scroll through the content of the modal itself so that I can see all of the elements within…
- With this much content within the modal the top and the bottom borders of the modal are not even visible within the window… they appear to be cut off from the browser viewport, and no matter how far you scroll up/down they do not become visible.
Any help would be greatly appreciated. Please let me know if I can provide anymore info for troubleshooting! Thanks very much (i’m a newbie)
Andrew
Issue Analytics
- State:
- Created 8 years ago
- Reactions:4
- Comments:5
Top Results From Across the Web
How to scroll the page when a modal dialog is longer than the ...
@Adyyda You can stop scrolling by wrapping the page in a DIV with overflow:hidden and settings its size to the same as the...
Read more >How to prevent overflow scrolling in CSS - LogRocket Blog
To fix this problem, avoid using vw for your max-width and use a max-width of 100% instead. This will transfer the width of...
Read more >Prevent Page Scrolling When a Modal is Open | CSS-Tricks
Unfortunately overscroll-behavior: contain does not prevent the scrolling when the content is less or equal to the parent(as in, no overflow).
Read more >Modal Not Scrollable - Material Design for Bootstrap
Hi there, All the modals when open up are not scrollable on any screen size if the modal height is big. Please help...
Read more >Modal · Bootstrap v5.0
You'll likely run into issues when nesting a .modal within another fixed ... You can also create a scrollable modal that allows scroll...
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
@andrewheppner Hi Andrew, actually that is not an issue with react-modal or react for that matter. It’s CSS positioning.
Since the modal is absolutely positioned, it is out of the document bounds, in other words the document, does not know how big the modal is and has no idea that it is bigger than the document itself and therefore doesn’t scroll.
This can be fixed by giving the modal a fixed height and setting the
overflow
property toscroll
. Try the code below, I just tested it and it works perfectly.This is more complicated than the above solutions.
It’d be nice if all this were built into react-modal’s default CSS with some
centerAndScrollable
prop defaulted totrue
.🤷♀️