It appears that the React MUI Grid is causing the page or its container to experience overflow issues

I'm utilizing Grid to maintain the organization of the entire page, but I keep encountering an overflow issue when adding multiple Grid items. This results in the scrollbar appearing even though the container size remains the same. Dashboard.tsx is part of React-Router V6's Outlet, although it may not be relevant to the issue.

Apologies for any redundant code as I am still learning and navigating my way through this.

App.tsx (excerpt)

    <Box sx={{ display: "flex" }} id="nav">
      <NavBar />
        <Box component="main" sx={{ flexGrow: 1 }} id="page-body">
          <Toolbar />
          <Outlet />
      </Box>
    </Box>

Dashboard.tsx

    <Box
      sx={{
        padding: "20px"
      }}
    >
      <Grid container>
        <Typography variant="h3" sx={{ marginBottom: "20px" }}>
          Dashboard
        </Typography>
        <Grid
          container
          item
          xs={12}
          component={LocalizationProvider}
          dateAdapter={AdapterDayjs}
        >
          <Grid container item columnSpacing={2} rowSpacing={4}>
            <Grid item container xs={12}>
              <Grid
                item
                container
                component={Card}
              >
                <JobDetailPieChart />
              </Grid>
            </Grid>
            <Grid item container xs={12} lg={7}>
              <Grid
                item
                container
                component={Card}
              >
                <MachineRuntimeGantt />
              </Grid>
            </Grid>
            <Grid item container xs={12} lg={5}>
              <Grid
                item
                container
                component={Card}
              >
                <DefectParetoChart />
              </Grid>
            </Grid>
          </Grid>
        </Grid>
      </Grid>
    </Box>

MachineRuntimeGantt.tsx (similar structure with other chart components)

    <Grid item container component={Box} sx={{ padding: "20px" }} spacing={2}>
      <Grid container item xs={12} alignItems="center">
        <Grid item xs={6}>
          <Typography variant={"h4"}>Machine Runtime</Typography>
        </Grid>
        <Grid item xs={6}>
          <DatePicker
            label="Select Month"
            views={["month", "year"]}
            aria-label="select-month-year"
            value={selectDate}
            onChange={(newDate) => {
              setSelectDate(dayjs(newDate))
            }}
            slotProps={{
              textField: {
                fullWidth: true,
                InputLabelProps: { shrink: true }
              }
            }}
          />
        </Grid>
      </Grid>
      <Grid item xs={12}>
        <Divider sx={{ borderBottomWidth: "4px" }} />
      </Grid>
      <Grid item xs={12}>
        <HighchartsReact
          highcharts={Highcharts}
          options={options}
          ref={chartComponentRef}
          {...props.chart}
        />
      </Grid>
      <ChartLegend errorTypeList={errorTypeList} />
    </Grid>

It appears that having multiple rows in the Grid causes an overflow issue, but the reason behind this is unclear to me.

The overflow occurs when including all three components or two of the same components. However, having the components on separate rows prevents this issue.

Answer №1

Appreciation to everyone who contributed to formatting the question! I have come to the conclusion that the issue lied in the appearance of the vertical scrollbar which inadvertently triggered the horizontal one as well. This was rectified by:

html {
  ...
  overflow: auto;
}

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

Are you encountering an issue with your React application while attempting to retrieve JSON data?

I recently developed a Home.js component and integrated it within the App.js file of my React application. However, I am encountering an error when trying to fetch JSON data. The error message is displayed at this link: https://i.stack.imgur.com/hGkN3.png ...

The background color of the active tab is updated upon loading the page

I have attempted to modify this code to change the background color of li tag on click. It successfully changes the background color when hovering or clicking, but unfortunately reverts back to the default color upon page refresh. I am looking for a soluti ...

Creating colorful containers using Bootstrap

Hey there, I am interested in creating small colored boxes to represent different meanings for each color. I came across this code snippet but I am unsure how to adjust the size: <div class="p-3 mb-2 bg-primary text-white">.bg-primary</d ...

Instructions for creating a Google Maps overlay that hovers above the zoom bar

Let me share my workaround for creating an overlay and dealing with z-index issues when using Google Maps API. The problem arises when dragging the map and the overlay ends up behind control elements like the zoom bar. No matter how much I adjust the z-ind ...

I am unable to view the product even though its ID is visible in the URL

import Container from "@/app/components/Container"; import ProductDetails from "./ProductDetails"; import Reviews from "./Reviews"; import { Products } from "@/utilities/Products"; interface Iparams { productid?: ...

Library of CSS styling information

Has anyone come across a reliable javascript library that can retrieve the original style (not computed) of a specific element in the DOM? Essentially, I am looking for something that can provide results similar to what is displayed in Firebug's style ...

The value of type 'X' cannot be assigned to type 'Y' or 'undefined'

In my code, there is a component that requires a prop with an enum value: export enum AType { some = "SOME", word = "WORD", } const MyComponent = (arg: AType) => {} When I try calling this component like so: <MyComponent ar ...

How can one correctly initialize a class within React?

What is the recommended approach for initializing a class in a React component and ensuring that only one instance of the class is maintained throughout the component's lifecycle? Let's consider the following scenario: // MyClass.ts class MyClass ...

When utilizing the JavaScript createElement() method to create elements on keydown, it will not be compatible with jQuery's draggable() method

I'm currently developing a drag and drop feature for a project, allowing users to add items to a work area and then position them by dragging. I'm facing an issue where I want to create multiple instances of the same element using a key code, but ...

Is it possible to protect assets aside from JavaScript in Nodewebkit?

After coming across a post about securing the source code in a node-webkit desktop application on Stack Overflow, I began contemplating ways to safeguard my font files. Would using a snapshot approach, similar to the one mentioned in the post, be a viable ...

Click to reveal the hidden div located at the bottom of the webpage

I have created a simple webpage where all the content is visible without the need to scroll down. However, there is additional content at the bottom that I want to keep hidden until the user chooses to see it. The idea is to have a phrase at the bottom o ...

What are the tips for aligning this button perfectly on the page, despite being centered in a computer's resolution?

Dealing with Responsive Design Hey there! I'm having an issue with my Bootstrap layout. I managed to center a button, but when I adjust the resolution or make it smaller, the button wraps and shifts to the right. Can anyone help me figure out what we ...

Increased space between the sidebar and the top bar

Currently, my code is a bit messy as I am still in the learning stages of bootstrap. I need some assistance on how to resolve the empty space that exists between the top and side bar elements. <!DOCTYPE html> <html lang="en"> <sty ...

Utilize the map function to handle event.target.name and associate multiple values with the index of the map

The current functionality only allows for running one component (i.e. "ComponentTwo"). I am looking to extend it to accommodate more components, but encountering an issue with the map function passing the same value to all components in the loop. There are ...

Is there a way to shift my navigation to the right while keeping the (display: inline;) property intact?

Is there a way to align my navbar to the right side while keeping the display: inline; property intact? When I remove the display: inline; property, the li elements automatically align to the right side of the page, but in a list format. HTML <div id= ...

Creating diamond-shaped columns and rows in HTML using the Bootstrap framework is a fun and creative way to

Recently, I tackled the challenge of building a website based on a specific design. Within this design, there was a div element that included an image link. Despite my efforts, I found myself at a loss on how to proceed with this task. Here is the snippet ...

Extensive content within the v-autocomplete field

I am trying to use the v-autocomplete component to display the entire text of the selected item. On initial selection, everything displays correctly: However, once it is chosen, only a portion of the text is shown, leaving out important information: ...

An image spanning two columns on a page with three columns

I am currently utilizing Foundation 4 for my website design. I am attempting to create an image that spans over 2 columns in a 3-column layout using the Foundation grid system. Here is how I envision it: I am wondering if it is possible to achieve this by ...

What steps should I take to ensure that the content within a div also goes full screen when I expand the div?

Is there a way to make a flash game go full screen along with its container div? I have a button that expands the div to full screen, but the flash game inside remains stuck in the top left corner of the screen. How can I ensure that the flash game expands ...

Experience the full power of the bootstrap grid system with a unique feature: nested overflow-y scrolling

Struggling with the bootstrap grid and a nested div with overflow-y. I followed advice from this stack overflow post, attempting to add min-height:0 to the parent ancestor, but can't seem to make it work. View screenshot here - Chrome on the left, Fi ...