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

What is the best way to target outer elements only using CSS selectors?

Having trouble with a CSS selector: $("td.cv-table-panel-element") This selector returns a list of elements, shown in the screenshot linked below: https://i.stack.imgur.com/RoVMj.png Each element represents a column in a table with unique content. The ...

Using a conditional statement in JavaScript, create a mapping between the values in an array and string

I have a dropdown list that I want to populate with options. The functionality of the onchange event is handled by the following code snippet: const handleChange = (event) => { onFilterChange(filterName, event.target.value); } The value of event.ta ...

Showing nested div elements in a single row

I'm currently dealing with a react component that generates nested divs. My goal is to make sure all the divs are displayed on the same line, but the catch is I can only apply styles to the outermost container div. Is there a way to achieve this witho ...

Scrolling with Jquery window.scrollTo results in the page becoming unresponsive

I'm currently revamping a website that features a header with 100% screen height, but I need it to shrink down to 0px when a user starts scrolling. The issue I'm facing is that once the header shrinks to 0px, the page content ends up slightly abo ...

What are the steps to access ember paper icons without an internet connection?

I'm currently working on a web module using Ember Paper that I need to be able to use offline. However, when in offline mode, the Ember Paper icons are not displaying and only text is visible. Can someone assist me in making Ember Paper work properly ...

Is there a way for my React app to display a 404 error page for a non-existent document?

Hey there! I recently submitted my website to a search engine, but encountered an error stating "Your non-existing pages don't return status 404". I'm not sure how to go about returning this status. I've been trying to solve this issue, but ...

What is the proper method for appending a string to the id of a React JSX div element?

Is it possible to dynamically change the id of a div in JSX using the following code snippet? { ['A','B','C','D'].map((element, cell) => ( <div id="alphabet_{element}"> Some </div> )) ...

Attempting to modify the background hue of a grid component when a click event is triggered

I am struggling with the syntax to change the color of an element in my grid when clicked. I have attempted different variations without success. Being new to JavaScript, I would appreciate some gentle guidance if the solution is obvious. JS const gri ...

Creating a Jquery method to handle multi-line ellipsis for long text

Check out this fiddle I made: http://jsfiddle.net/mupersan82/JYuSY/ This snippet handles multiline ellipsis: $(function() { var ellipsisText = $('.multilineEllipseText'); var textContainer = $('.incidentCellBottomRight').height(); whi ...

What could be causing my difficulty in locating an HTML element using jQuery/JS string interpolation?

In my project, I have a set of div blocks each identified by a unique numerical id. For instance: One of the tasks in my project is to select the 29th element following a specific chosen element. For example, if I choose the first div with id 1, then I s ...

Having trouble accessing a jQuery function in the componentDidMount() of a React component from a separate .js file

I have been diving into the world of jQuery for quite some time now and it has been a rewarding process. However, there is one particular challenge that I am currently facing. Despite my efforts to find a solution on my own, the answers I came across were ...

Uncovering components generated by React JS with BeautifulSoup

My goal is to extract anchor links with the class "_1UoZlX" from the search results on a specific page - After analyzing the page, I realized that the search results are dynamically generated by React JS and not readily available in the page source or HTM ...

result produced by a callback function

Having difficulty retrieving the returned value by the callback function ("dist" = undefined) despite numerous attempts. However, I am able to retrieve it from the console. Seeking assistance from someone knowledgeable in this area! calculateDistance = ...

Tips for identifying issues with a malfunctioning filter in ReactJS

Upon attempting to delete unwanted data by clicking the "delete" button using filter, I am encountering an issue where it is not working and there are no bug notifications. This leaves me unsure of how to proceed with my project. import ColorCards from &qu ...

Tips for showcasing API data in React buttonsHow to exhibit information fetched from API in

My goal is to present the array of data received from different API calls, such as /fruits and /pizza. I aim to format this data into a table that separates each element in the json array. How can this be achieved in React, assuming the API code functions ...

Looking for a way to identify when a DOM element is resized as a result of web fonts loading asynchronously?

Within this div element lies text styled with a custom font via CSS's @font-face attribute. The issue arises when the font hasn't loaded yet, causing a delay in updating the font style of the text within the div. As a result, taking measurements ...

Step-by-step guide on positioning a div below another div and centering both elements horizontally

Trying to center the "input" div below the "InputBelow" div using "flex-direction: column" is causing issues with "justify-content; center." The goal is to center the main "border" div in the middle of the screen and align the other elements inside it. ...

What is the best way to access the original observed node using MutationObserver when the subtree option is set to

Is there a way to access the original target node when using MutationObserver with options set to childList: true and subtree: true? According to the documentation on MDN, the target node changes to the mutated node during callbacks, but I want to always ...

React and the turn.js library (please note that turn is not a predefined function)

I'm trying to integrate turn.js with React by following an example I found here: https://codesandbox.io/s/005xlk45mn After adapting the code to my project, I encountered the following error: TypeError: jquery__WEBPACK_IMPORTED_MODULE_6___default(... ...

establishing irregular edges for the div container

Looking to create a class that can transform an element into a specific shape using CSS. Not entirely sure if this is achievable with pure CSS alone, but applying a class to the image element will morph it into the desired shape as shown below. <style ...