Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't scroll menu items in selects. #10601

Closed
duvet86 opened this issue Mar 10, 2018 · 25 comments
Closed

Can't scroll menu items in selects. #10601

duvet86 opened this issue Mar 10, 2018 · 25 comments
Labels
bug 🐛 Something doesn't work component: select This is the name of the generic UI component, not the React module!
Milestone

Comments

@duvet86
Copy link
Contributor

duvet86 commented Mar 10, 2018

Expected Behavior

I have a select with a little bit more than 100 items. When I open it and I try to scroll the items with the mouse wheel it doesn't scroll I have to drag the scroll bar.
It works briefly if I quickly open the select and use the mouse wheel.
It appears the menu list is loosing focus after opening.

Current Behavior

The list should be scrollable when the select gets clicked.

Steps to Reproduce (for bugs)

The issue is present on the selects demo page. Try to open a multiselect and scroll the items.

Material UI: 1.0.0-beta.36
Chrome 65

@oliviertassinari oliviertassinari added the status: waiting for author Issue with insufficient information label Mar 10, 2018
@oliviertassinari
Copy link
Member

oliviertassinari commented Mar 10, 2018

@duvet86 Your issue has been closed because it does not conform to our issue requirements.
Please provide a full reproduction test case. This would help a lot 👷 .
A live example would be perfect. This codesandbox.io template may be a good starting point. Thank you!

@thegregthomp
Copy link

Is this ever going to get addressed? It's broken on the documentation website, i think that's about all the test case needed and looking back at past issues, it seems to be a long standing one.

@oliviertassinari
Copy link
Member

@thegregthomp Do you have a reproduction example on v1-beta?

@thegregthomp
Copy link

thegregthomp commented Mar 23, 2018

@oliviertassinari I doesn't work on the website. Image and link provided. My guess is that this is chrome specific. I noticed it does scroll in responsive mode via 'touch' simulation and it also scrolls if I add overflow to the container

image

https://material-ui.com/demos/selects/

@oliviertassinari oliviertassinari added bug 🐛 Something doesn't work component: select This is the name of the generic UI component, not the React module! and removed status: waiting for author Issue with insufficient information labels Mar 24, 2018
@oliviertassinari oliviertassinari self-assigned this Mar 24, 2018
@oliviertassinari
Copy link
Member

oliviertassinari commented Mar 24, 2018

@thegregthomp You are right, I can reproduce the issue on https://material-ui.com/demos/selects/ with Chrome 65.
But I can't reproduce it on https://material-ui.com/demos/menus/#max-height-menus or with Safari and Firefox.

@oliviertassinari
Copy link
Member

I have no clue around how to address this issue 🤔 .

@oliviertassinari oliviertassinari removed their assignment Mar 24, 2018
@duvet86
Copy link
Contributor Author

duvet86 commented Mar 24, 2018

Ok, upon further investigation it is something to do with css and the page height.
At the beginning the whole page has a scroll bar but once you click on a select with a long list of options the page scroll bar disappears and you can't scroll the list. Even stranger is the fact that if you open the console the option list becomes scrollable.
All of this happening https://material-ui.com/demos/selects/ section Multiple Select, name select.
Cheers Luca

@eXamadeus
Copy link

eXamadeus commented Mar 28, 2018

@oliviertassinari I noticed something interesting when working with chrome and the broken lists on https://material-ui.com/demos/selects/. If you right click in the list once the scrolling stops, then hit escape to close the menu, scrolling works again. This is another odd way to make it start working again.

@duvet86's workaround is interesting as well. I wonder if the height is a red herring and it just has to do with element focus? Still not sure...

@philmill
Copy link

Has anyone tried updating to the latest beta-39 with the autofocus fix for Select included? I'm going to try it out but my app is a few beta versions behind and need to step through the breaking changes.
#10792

@darthneel
Copy link

Here is a workaround I am using which fixes the issue and supports the notion that the underlying problem is with focus.

<Select
  ...
  MenuProps={{
    onEnter: () => {
      setTimeout(() => {
        if (document.activeElement) {
          document.activeElement.blur();
        }
      }, 500);
    }   
  }}
>
  {children}
</Select>

@TheMoonDawg
Copy link
Contributor

Thanks for the workaround darthneel! This does the trick for now.

@byoungb
Copy link

byoungb commented Apr 20, 2018

@darthneel 's workaround doesn't work for me. I am working with a Menu that has a fixed height. In my case I can get the scroll wheel to work if I click on the Menu or scroll with the scroll bar then things pretty much work correctly. I think at least in my case something is wrong with the backdrop. because if I delete the backdrop then I can scroll with the mouse wheel without any problems.

@alozionn
Copy link

@duvet86 the strange thing that the list becomes scrollable when you open the dev tools, is not ABOUT the dev tools is about swaping out of the window and back into it(try alt+tabbing to another window), maybe somehow sending the signal to focus when the window is shown again.

@FernandoGOT
Copy link

FernandoGOT commented Apr 27, 2018

+1
The workaround worked for me, just add this to your TextField:

SelectProps={{
  MenuProps: {
    onEnter: () => {
      setTimeout(() => {
        if (document.activeElement) {
          document.activeElement.blur();
        }
      }, 500);
    }
  },
}}

@abukurov
Copy link
Contributor

abukurov commented May 3, 2018

Another workaround based on CSS:

<Select
  ...
  MenuProps={{
    PaperProps: {
      style: {
        transform: 'translate3d(0, 0, 0)'
      } 
    }   
  }}
>
  {children}
</Select>

@duvet86
Copy link
Contributor Author

duvet86 commented May 6, 2018

@oliviertassinari so I had time to spend on this and the issue lies on the Backdrop component of the Modal.
I can't replicate it on code sandbox so I've pasted the code here.

const BackdropComponent = ({ onClick }) => {
  return (
    <div
      style={{
        top: 0,
        left: 0,
        width: "100%",
        height: "100%",
        zIndex: -1,
        position: "fixed"
      }}
      data-mui-test="luca"
      onClick={onClick}
      aria-hidden="true"
    />
  );
};

const IntervalTypeSelector = ({
  classes,
  intervalTypes,
  selectedIntervalType
}) => (
  <FormControl className={classes.formControl}>
    <InputLabel htmlFor="interval">Interval</InputLabel>
    <Select
      MenuProps={{
        BackdropComponent
      }}
      value={selectedIntervalType}
      onChange={this.handleChange}
      input={<Input name="interval" id="interval" />}
      autoWidth
    >
      {intervalTypes.map(({ IntervalType, Label }) => (
        <MenuItem key={IntervalType} value={IntervalType}>
          {Label}
        </MenuItem>
      ))}
    </Select>
  </FormControl>
);

Replacing the backdrop component with one without Fade and therefore without Transition fixes the issue.
I believe react-transition-group/Transition is real responsible.
I need to dig deeper.

Cheers

@hermanho
Copy link

hermanho commented May 16, 2018

Here is another example that I am not sure if it is related to the same issue.
https://codesandbox.io/s/74j6r40zvj

Chrome 66 ❌
Firefox 60 ✔️
Edge 42 ✔️

When I remove the "Tabs" component in demo.js , it works.
https://codesandbox.io/s/2x49zj50j

@oliviertassinari oliviertassinari added this to the post v1.0.0 milestone May 20, 2018
@cmosboss
Copy link

Note I also noticed this on the demo website under multiple select https://material-ui.com/demos/selects/

Something I noticed is that it depends on HOW you scroll. If you open the menu and scroll down no issue, if however you scroll down and then up again it (pretend you are scrolling passed the top) it will then not respond to downward scrolls for a long period. Not sure if this is fixed and the demo page just needs updating.

@stclairdaniel
Copy link

I am also having this issue and none of the above workarounds work - I can't scroll with the scrollwheel at all.

@ghost
Copy link

ghost commented Jun 26, 2018

I'm seeing this in Chrome (not Safari) for a simple <List> of <ListItem> embedded in a <Popover>. It's definitely a focus issue, but since I'm not using a <Select>, I can't supply a MenuListProps prop to fix it.

Update: ah, but I can use "PaperProps" prop of the Popover:

PaperProps={{
  style: {
    transform: 'translate3d(0, 0, 0)',  // fixes a scroll issue: https://github.com/mui-org/material-ui/issues/10601
  },
}}

@asemoon
Copy link

asemoon commented Jun 27, 2018

I am seeing the same problem on chrome 67 while it works as expected in Firefox 60.
using @abukurov workaround, it fixed it on chrome.

@afilp
Copy link
Contributor

afilp commented Jul 23, 2018

Can @abukurov solution be included in the library core?

@oliviertassinari
Copy link
Member

oliviertassinari commented Jul 23, 2018

@afilp It's already here with #12003 thanks to @stephenway. What version are you using?

@afilp
Copy link
Contributor

afilp commented Jul 23, 2018

Thanks!

I am using the React Admin software which has MUI as a dependency:

https://github.com/marmelab/react-admin/blob/master/packages/ra-ui-materialui/package.json

@momguide
Copy link

momguide commented Sep 5, 2022

Another workaround based on CSS:

<Select
  ...
  MenuProps={{
    PaperProps: {
      style: {
        transform: 'translate3d(0, 0, 0)'
      } 
    }   
  }}
>
  {children}
</Select>

if you want to create scoll, then
write code like:
MenuProps={{ PaperProps: { style: { maxHeight: '33%' } } }}
it works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: select This is the name of the generic UI component, not the React module!
Projects
None yet
Development

No branches or pull requests