Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Material UI Drawer overflow causing scrollbar on body

I'm using a clipped under the app bar drawer with a canvas as the primary content. I have three collapsible cards in the drawer and when all set to be open by default, it shows a vertical scrollbar on the body and white space below the html element with the body element. If you close all three of the cards the scroll goes away. If you reopen the cards, the scroll doesn't appear. The issue only seems to occur when the page is loaded with all three cards open.

Our short term solution is to load the page with only two cards open, but I want to note even with two open, the drawer content extends below the window with no scroll. The CSS for the drawer shouldn't be the issue either. Anyone else experience this issue?

  drawerPaper: {
    position: 'relative',
    width: 400,
    overflowX: 'hidden',
    overflowY: 'hidden',
    '&:hover': {
      overflowY: 'auto',
    },
    '&::-webkit-scrollbar': {
      display: 'none',
    },
  },



   <MuiThemeProvider theme={this.state.useDarkTheme ? darkTheme : lightTheme}>
    <div className={classes.root}>
      <AppBar position="absolute" className={classes.appBar}>
        <Toolbar>
          <div className={classes.flex}>
            <Typography className={classes.headerTextColor} variant="title">
              Title
            </Typography>
            {sealedBy}
          </div>
          <HeaderTools />
          <Tooltip id="toggle-icon" title="Toggle light/dark theme">
            <IconButton className={classes.headerTextColor} onClick={this.toggleTheme}>
              <BrightnessMediumIcon />
            </IconButton>
          </Tooltip>
        </Toolbar>
        {spinner}
      </AppBar>
      <Drawer
        variant="permanent"
        classes={{
          paper: classes.drawerPaper,
        }}
      >
        <div className={classes.fixedWidth}>
          <div className={classes.toolbar} />
          <DocumentTools />
          <SealingTools />
          <AnnotationTools />
        </div>
      </Drawer>
      <main className={classes.content}>
        <div className={classes.toolbar} />
        <DrawingCanvas />
      </main>
    </div>
  </MuiThemeProvider>
like image 415
Seth Duncan Avatar asked Jun 26 '18 15:06

Seth Duncan


People also ask

How do I get rid of overflow scrollbar?

To hide the horizontal scrollbar and prevent horizontal scrolling, use overflow-x: hidden: HTML.

Why is overflow scroll always visible?

Make sure overflow is set to "scroll" not "auto." With that said, in OS X Lion, overflow set to "scroll" behaves more like auto in that scrollbars will still only show when being used. So if any the solutions above don't appear to be working that might be why. You can style it accordingly if you don't like the default.

How do I add a scroll bar in material-UI modal?

You need to use 'overflow = scroll' for modal style. Below is example code to get scrollable material-ui modal. withStyles is used to apply style for modal in this example.


1 Answers

You need to add height: 100% css property on some container components, and to styles to drawerPaper need add too.

I have setup here, its working, but probably depends on container components:

drawerPaper: {
    width: 250,
    overflow: "auto",
    height: "100%",
    [theme.breakpoints.up("md")]: {
      overflow: "auto",
      width: drawerWidth,
      position: "relative",
      height: "100%"
    }
  }
like image 179
dvvtms Avatar answered Oct 05 '22 14:10

dvvtms