I am encountering an issue while using MUI with React. I have a <Paper>
element wrapping a <Grid>
with 3 children elements. The problem arises when I set the overflowY property of the bottom grid item to "auto" - instead of showing the scroll bar when the content exceeds the container size, it breaks the parent container. Here is my code snippet:
<Paper
elevation={0}
style={{
height: "776px",
width: 342,
overflowY: "hidden"
}}
>
<Grid
container={true}
direction="column"
style={{ overflowY: "hidden" }}
>
{
<Grid
container={true}
item={true}
style={{
flexGrow: 1,
padding: "16px",
width: "100%",
flexWrap: "nowrap",
position: "sticky",
top: 0
}}
>
{props.pageTitle && (
<Grid item={true} style={{ marginTop: 6 }}>
{!filterOpen && (
<Typography variant="h6">
<span
style={{
paddingLeft: 8
}}
>
{props.pageTitle}
</span>
</Typography>
)}
</Grid>
)}
{props.allowFilter && (
<Grid justify={"flex-end"} container={true} item={true}>
<FmsFilterBox
filterText={filterText}
onChange={setFilterText}
cssFilterBoxWidth="100%"
onFilterOpenChanged={setFilterOpen}
/>
</Grid>
)}
</Grid>
}
<Grid item={true} style={{ flexGrow: 1 }}>
<Divider style={{ width: "100%" }} />
</Grid>
<Grid
item={true}
style={{
flexGrow: 1,
overflowY: "auto"
}}
>
{props.children(filteredData)}
</Grid>
</Grid>
</Paper>
https://i.sstatic.net/aqPYz.png
https://i.sstatic.net/u23Zm.png
I have tried various solutions but I cannot get the scroll bar to appear for the third (bottom) grid item which renders {props.children(filteredData)} containing a list fetched from the backend.
If I remove the overflowY: "hidden"
from the <Paper>
, the content of the third grid item gets hidden without displaying the scroll bar - as shown in the attached images.
I am seeking assistance as I have exhausted all my ideas. Has anyone else encountered this issue before? Thank you.