Issue with MUI Grid item not functioning properly when using overflowY: "auto"

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.

Answer №1

Solved the issue by setting a height value of 100% on the primary grid (main container) and adding a flex-wrap property with a value of "no-wrap".

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

yarn.lock file contains a vulnerability related to serialize-javascript

After creating a React project with the npx create-react-app my-app command and testing it using npm start, I encountered a security advisory on the Github page when committing the project. A vulnerability in serialize-javascript was found in yarn.lock * ...

Switch the toggle to activate or deactivate links

My attempt at coding a switch to disable and enable links using CSS is functional in terms of JavaScript, but the appearance is not changing. I am lacking experience in this area. Here is my HTML Button code: <label class="switch" isValue="0"> ...

AngularJS and CSS: A Guide to Effortlessly Toggle Sliding List Elements

I am in the process of developing a drop-down menu that can be clicked. Using my custom AngularJS directive, I have successfully implemented functionality to load menu items dynamically. While I have made significant progress, I have encountered a small i ...

Find the JavaScript code that selects the previous value chosen

When working with a select in React, I am facing an issue where the console.log is returning the last value selected instead of the current one. For instance, if I select 4 followed by 3 and then 5, the code will display 1 (default value), then 4, and fin ...

Unlocking the Potential of NextJS with Dynamic Page Export - Say Goodbye to Static HTML!

I am attempting to export my NextJs project based on the official documentation provided. However, it seems that I can only export it into static HTML. Is there a way to export it into dynamic pages where user-submitted data is updated in real time, simil ...

I did not anticipate the React setState function to behave in the manner it did

While working on form validation for my page, I came across a tutorial showcasing a validation method that seems to be functioning correctly. However, there is one aspect that I am struggling to grasp. The tutorial suggests declaring a variable before the ...

The navigation bar alignment to the right is malfunctioning

I'm puzzled as to why the navbar-right class is not properly closing out the two navigation bar elements on the right. Despite adding the correct code, it doesn't seem to be working as expected. <nav class="navbar fixed-top navbar-toggleable- ...

How to access the public folder in React from the server directory

I am having an issue with uploading an image to the react public folder using multer in NodeJs. Everything was working fine during development, but once I deployed it, the upload function stopped working. It seems like the multer is unable to reference or ...

Error encountered with structured array of objects in React Typescript

What is the reason for typescript warning me about this specific line of code? <TimeSlots hours={[{ dayIndex: 1, day: 'monday', }]}/> Can you please explain how I can define a type in JSX? ...

Having trouble with Flowbite dropdown functionality in Next.js 12.* with Tailwind CSS

Hello, I am a newcomer to Next.js and currently working on a project using Tailwind/Flowbite. I copied and pasted the Flowbite search input with dropdown code from , but unfortunately, the dropdown is not functioning as expected. I have followed the docum ...

Navigating through a dictionary in React TypescriptWould you like to learn

Currently, I am delving into the world of React and TypeScript. Within my journey, I have stumbled upon a dictionary representing various departments, with employee data stored in arrays. type Department = { Emp_Id: number, Name: string, Age: n ...

Embedding the scrollbar within the div container

I'm having trouble placing my vertical scrollbar inside my div and adjusting its position. To streamline the code, I have extracted a portion below: .toprightcontrols { margin: 0 3% 0 0; display: flex; position: absolute; justif ...

The hyperlink to a different webpage does not trigger any JavaScript functionalities or render any CSS styles

I am facing an issue with linking HTML pages that run Javascript and JQuery Mobile from another HTML page. My link setup is as follows: <a href="hours.html">Hours</a> The linking page and the linked pages are in the same directory. However, ...

I am encountering an issue where the characters "£" is displaying as "£" when my HTML is rendered. Can anyone explain why this is happening?

Here is the code I'm having trouble with: http://pastebin.com/QBLeLyNq. For some reason, the "code" part isn't working correctly. Any help would be appreciated. I used to run a small business and had a profit of £145 with an investment of only ...

The concept of vertical alignment within the CSS Grid system

I am attempting to utilize CSS grids in order to vertically align an unordered list. However, I am encountering the following layout: *A******* *B * *C******* ********* * * ********* ********* * * ********* While the grid template rows a ...

What's the best way to establish a Next.js global context without triggering a "Text content did not match" error?

I am currently working on a next.js App where I need to fetch SESSION data into a global context. This is how my code looks like: // _app.js const App = ({ Component, pageProps }) => { const start = typeof window !== 'undefined' ? window.se ...

The deployment on heroku encountered an error during the build process

I'm attempting to deploy my React application on Heroku, but I keep encountering the following errors: -----> Installing dependencies Installing node modules npm ERR! code ERESOLVE npm ERR! ERESOLVE could not resolve npm ...

Click event triggering smooth scrolling

I am currently working on implementing a smooth scrolling effect using the React JavaScript library without relying on jQuery. My goal is to ensure that when a user clicks on a link, they are directed to the specific section of the page seamlessly. The f ...

Ways to insert a hyperlink within a div element

Consider the following HTML structure: <article id="1919"> <div class="entry-content clearfix"> <div></div> <div></div> </div> </article> &l ...

What is the best way to format the alignment of inline child elements using the MUI5 sx prop?

I am looking to create a MUI container with multiple sub-components that need to be displayed inline but separated by a fixed padding. One way I have achieved this is: <Box sx={{display: 'flex', '& > * + *': {ml: 2}}> &l ...