siriwatknp / mui-treasury

A collection of ready-to-use components based on Material-UI
https://mui-treasury.com
MIT License
2.38k stars 150 forks source link

Horizontal scrollbar when sidebar is collapsed #868

Open mauro-ni opened 4 years ago

mauro-ni commented 4 years ago

@siriwatknp I'm using version 4.4.1 of mui-treasury/layout and I noticed that when the sidebar is collapsed (only icons are visible) then it is scrollable horizontally (in Windows you get the annoying scrollbar). This is due to the overflow property set to auto.

Version 3 of mui-treasury/layout doesn't have this bug, since overflow css property is set differently:

# MuiPaper inside MuiDrawer
overflow-y: auto;

# Second child of MuiPaper
overflow: hidden auto;

Many thanks.

Mauro

Technologeek commented 4 years ago

@siriwatknp Can I pick up this up as my first issue?

siriwatknp commented 4 years ago

@Technologeek thanks, you might want to look at DrawerSidebar.tsx.

Technologeek commented 4 years ago

Cheers! Will create a PR soon!

RITIKHARIANI commented 4 years ago

@siriwatknp and @Technologeek Has this issue been fixed yet?

mauro-ni commented 4 years ago

@siriwatknp and @Technologeek Will this bug be fixed in the near future? Many tahnks.

dimyG commented 4 years ago

A quick solution is to make the collapsed width a little bigger. For example using 74px instead of 64 solved the issue.

scheme.configureEdgeSidebar(builder => {
builder
     .create('main_sidebar', { anchor: 'left' })
     .registerTemporaryConfig('xs', {
      anchor: 'left',
      width: 'auto', 
    })
    .registerPermanentConfig('md', {
      width: 256, 
      collapsible: true,
      collapsedWidth: 74,
    });
});
mauro-ni commented 3 years ago

There are 2 horizontal scrollbars, here are my workarounds:

1) As suggested by @dimyG I modified collapsedWidth, setting it to 65 solve the problem 2) I defined a style class and conditionally applied it to the

import clsx from 'clsx';

const useStyles = makeStyles((theme) => ({
  sidebarOverflowFix: {
    overflowX: 'hidden !important',
    overflowY: 'auto !important',
  },
}));

...

{({ state: { sidebar } }) => {
  return (
    ...
    <DrawerSidebar sidebarId="left_sidebar">
      <SidebarContent className={clsx(sidebar.left_sidebar.collapsed && classes.sidebarOverflowFix)}>
        <AppSidebar collapsed={sidebar.left_sidebar.collapsed} />
      </SidebarContent>
      <CollapseBtn>
        {({ collapsed, anchor }) =>
          collapsed ? <ArrowForwardIcon /> : <ArrowBackIcon />
        }
      </CollapseBtn>
    </DrawerSidebar>
    ...
  );
}}

...
Avni1802 commented 2 years ago

Can i pick this issue?