First off, I tried this simplified in the Browser https://codesandbox.io/s/competent-bassi-yjtoj and it works as expected.
In my project I'm using Electron, React and MUI and plain CSS. I do not know which of these is causing the issue. It might be simply that the CSS / Flexbox code is not correct?
Video demonstrating the issue: https://youtu.be/ym9Bhgexycs
Notice that once you try to scroll to the "bottom" in the inner container, you need to continue to scroll which is taken over by the main container; which then scrolls to the bottom of the outer container, to see the bottom of the inner container.
I tried several combinations. Disabled the outer containers overflow and set it to hidden
and used auto
for the inner container. Which I believe is normally correct because that's the behavior I want, to have the inner container scrollable only. In that case the inner container gets cut off and I can not scroll inside the inner container to the bottom. The scroll bar simply disappears because I am scrolling in a non see-able area.
The outer container has correct height and is not overflowing the status bar / footer.
The inner container clearly overflow the statusbar.
I also disabled all window related options in Electron in other tries but the issue persists.
It's a bit hard to provide a code demo illustrating the issue but here are the "main" parts which the video shows.
Globals
const styles = () => ({
'@global': {
'html,body': {
height: '100%',
margin: 0
},
'*': { minHeight: 0 }, // Seems to have no effect.
'#parcel-root': { // Probably not needed.
height: '100%',
margin: 0
}
}
})
Component
container: {
height: '100%',
width: '100% !important',
display: 'flex',
flexDirection: 'column',
minHeight: 0, // Suggested by Felix here but had no effect.
},
content: {
flex: 1,
overflow: 'auto',
},
subContainer: {
height: '100%',
width: '50%',
display: 'flex',
flexDirection: 'column',
backgroundColor: 'blue'
},
subContent: {
flex: 1,
overflow: 'auto',
backgroundColor: 'grey'
},
<div className={classes.container}>
<div name="TITLE">TITLE</div>
<div name="CONTENT" className={classes.content}>
SUB TITLE
<div className={classes.subContainer}>
<div className={classes.subContent}>
----- MY SCROLLABLE SUB COMPONENT DATA ----
</div>
</div>
</div>
<div name="FOOTER">FOOTER</div>
</div>
All dependencies used are the newest releases.
Thanks in advance for your time.
EDIT
The only work-around I have found is using:
height: calc(100vh - 35px)
applied to subContainer
but I have no idea where those 35px are coming from. I removed padding of all elements. I would like to find a real solution which is not based on a fixed pixel size .. or at least understand what is actually causing this issue.