I am having trouble scrolling through the main content when the side-drawer is open. How can I fix this issue?

When the sidebar is opened, I am facing issues with the main content scroll and certain fields such as select options and search bar not functioning properly. I have included the main content in the routes from which it is being loaded. However, the scroll and other functions mentioned work perfectly fine when the side-drawer is closed. As a newcomer to material ui + react, I have tried implementing various tips from different sources but have been stuck on this issue for quite some time.

  <>
      <Box sx={{ display: "flex" }}>
        <AppBar
          sx={{ backgroundColor: "rgb(19, 71, 129)" }}
          position="fixed"
          className={classes.appBar}
        >
          <Toolbar align="center">
            <IconButton
              color="inherit"
              onClick={handleMenuClick}
              edge="start"
              className={clsx(classes.menuButton)}
            >
              <MenuIcon />
            </IconButton>
          </Toolbar>
        </AppBar>
        <Drawer
          className={classes.drawer}
          variant="temporary"
          open={open}
          transitionDuration={{
            enter: transitionDuration,
            exit: transitionDuration,
          }}
          classes={{
            paper: classes.drawerPaper,
          }}
        >
          <Toolbar>
            <IconButton
              sx={{ marginLeft: "auto" }}
              onClick={handleMenuClick}
              edge="start"
              className={clsx(classes.menuButton)}
            >
              <ChevronLeftIcon />
            </IconButton>
          </Toolbar>
          <div className={classes.drawerContainer}>
            {/* //Drawer Items */}

            <DrawerItems open={open} isAdmin={isAdmin} />
          </div>

          {/* Logout */}

          <LightTooltip title="Logout" placement="top">
            <IconButton
              sx={{ marginTop: "auto" }}
              onClick={handleLogout}
              color="error"
            >
              <ExitToAppIcon />
            </IconButton>
          </LightTooltip>
        </Drawer>
        {/* Routes for drawer components */}
        <main
          className={clsx(classes.content, {
            [classes.contentShift]: open,
          })}
        >
          <Routes>
            <Route path="dashboard" element={<Dashboard />} />
            <Route path="employees" element={<Employees />} />
            <Route path="payroll" element={<Payroll />} />
            <Route path="projects" element={<Projects />} />
            <Route path="leaves" element={<Leaves />} />
            <Route path="leavesemp" element={<LeavesEMP />} />
            <Route path="empattendance" element={<EMPAttendance />} />
            <Route path="hrattendance" element={<HRAttendance />} />
          </Routes>
        </main>
      </Box>
    </>

This represents the style:

drawerContainer: {
    overflow: "auto",
  },
  content: {
    flexGrow: 1,
    padding: theme.spacing(3),
    transition: theme.transitions.create("margin", {
      easing: theme.transitions.easing.sharp,
      duration: transitionDuration,
    }),
    marginLeft: 0,
  },
  contentShift: {
    transition: theme.transitions.create("margin", {
      easing: theme.transitions.easing.easeOut,
      duration: transitionDuration,
    }),
    marginLeft: drawerWidth,
  },

Answer №1

Feeling rushed, I decided to implement a "persistent" mui drawer variant which successfully resolved the issue at hand. However, I am still committed to finding a more permanent solution for this specific problem.

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

Customized function enabling dynamic menu display based on varying screen dimensions

Looking for assistance with JS and jQuery as I am relatively new to it. Any help would be greatly appreciated... I'm currently working on a responsive header where I want to implement onclick functions for mobile and tablet resolutions only. I' ...

Changing an HTML container using jQuery and Ajax to facilitate a login process

Currently, I am on the lookout for a unique jQuery plugin that can replace a div when a successful login occurs. Despite searching multiple times on Google, I have been unable to find an ideal plugin that meets my specific needs. Do any of you happen to kn ...

The Shell Application is not refreshing React HtmlElement Micro Front end

I am currently facing an issue when trying to inject the following React MFE into another Angular shell application. The MFE loads successfully the first time, but if it is hidden or removed from the DOM and then reloaded, it fails to load. Could you plea ...

Having trouble with your JavaScript regex not functioning properly?

I am currently working with an array of arrays and I need to iterate through it to retrieve each word, excluding any "@", punctuation, and hashtags. However, my regular expression seems to be removing certain words entirely from the array and I can't ...

Is the useNavigate() function failing to work consistently?

Currently facing an issue while working on a MERN Web App. When logging in with an existing account, the backend API call returns user properties and a JWT Token. Upon saving it, I use the navigate function to redirect the User to the homepage. Everything ...

Updating the angular $resource method

I need to customize the query()-method of AngularJS $resource by using a custom $http-GET. However, it doesn't seem to be overriding the operation correctly. The result I am getting is an object with method, data, and headers, instead of data.rows[]. ...

Retrieve the scrolling height in Vue.js 2 window

I need to apply the sticky class to the navbar when a user scrolls down, and remove it when they scroll back up. To achieve this, I am attempting to calculate the scrolled height. Currently, my code looks like: mounted(){ this.setUpRoutes(); wind ...

What could be causing my cross fade to not repeat as intended?

I created a basic background image cross fader using the code found at http://jsfiddle.net/jRDkm/2/. This code was inspired by . However, I'm encountering an issue where the slideshow only repeats once before fading to white. How can I modify the cod ...

Is there a way to retrieve the controller instance linked to a directive within the link function?

Is there a way to retrieve the controller instance connected with a directive within the link function? return { template: template, controller: controller, controllerAs: 'myCtrl', // What is the method for ac ...

AngularJS inputs using ng-model should be blank when in the pristine state

Check out this input element within an HTML form: <input ng-model="amount" /> Currently, the input displays as $scope.amount = 0 in the controller. I want to start with a blank input field instead. This way, users can easily input data without havi ...

Trouble with targeting a specific css class

Can someone help me with a CSS issue I'm experiencing? Here is my code: <div class='test'> <div>test 1</div> <div>test 2</div> </div> <div class='test'> <div>test 3&l ...

Changing the `$location.path` updates the URL without triggering a redirect

When I try to redirect to another page by clicking a button or a link, the URL changes but the redirection doesn't happen. I have to manually refresh the page with the new URL. I'm not sure if the issue lies in the module or the controller. loca ...

relocate HTML components

I've been trying to reposition HTML elements within the body of a webpage, but I'm struggling with getting a form tag to appear exactly in the center of the browser - and only that form tag. Can anyone offer guidance or suggest relevant topics fo ...

Trouble encountered while executing npm run build using create-react-app

I created a small react application using the create-react-app template. The app functions properly when serving the content with npm run. However, when attempting to run the builder for the first time to showcase a demo, I encountered an error while exec ...

displaying a shadow solely on the left side of an image

When using jQuery to append an img element and apply a box-shadow on click, I am only seeing the shadow appear on the left side of the image. How can I make the box shadow show up on all sides of the image? var someNumbers = [1, 2, 3]; $.each(someNumbe ...

The body can only stretch up to a certain percentage of its width, not a full 100%

Recently, I've been encountering an issue with my webpage where the body does not stretch 100% the width of the screen. I've tried numerous CSS rules to fix it, but nothing seems to be working. When you view the page in a browser, it appears to c ...

Exploring a JSON Object with nested properties, crafting changes, and producing a fresh object: A step-by-step guide

I am attempting to manipulate a JSON object with nested properties by replacing numeric values with computed values and returning a new object. The original object looks like this: var obj = { "a0": { "count": 41, "name": "Park", "new": { ...

The TextField component in Material UI keeps its value visible even when typing in the field, unlike other components where the value is hidden

Since diving into Material UI, I've encountered an odd issue with the hintText in a TextField Component from Material UI. Below is my code snippet: /* in my component ... */ /* ... */ render() { const actions = [ <FlatButton ...

Discover the process of sending files to an external API using Use Server in NextJS 14

Just a heads up: I have to use a Server Page for this project, otherwise I would have used a "client side" component with axios. I'm attempting to upload a file to my external express server. However, when sending it to the API route, the req.files.f ...

hiding elements yet passing down

Despite disabling the style sheet, a dynamically created form is displaying strangely. This form will show or hide various details based on selected options. For instance, many of the elements are generated with C#.net... formOutput += "<div class=&bs ...