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

Autocomplete component don't lock screen when opened #27686

Closed
sandroweb opened this issue Aug 10, 2021 · 7 comments
Closed

Autocomplete component don't lock screen when opened #27686

sandroweb opened this issue Aug 10, 2021 · 7 comments
Labels
component: autocomplete This is the name of the generic UI component, not the React module! duplicate This issue or pull request already exists

Comments

@sandroweb
Copy link

In Select component, when to open, screen will be locked, but the same feature don't occure with Autocomplete component.

This problem cause a problem. When my page is scrolled, the list opened go up too.

Any one help me please?

Screen video with this problem: https://www.loom.com/share/b89ca160eb314b728c025ee9fde65c47

@sandroweb sandroweb added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Aug 10, 2021
@eps1lon

This comment has been minimized.

@eps1lon eps1lon marked this as a duplicate of #17353 Aug 11, 2021
@eps1lon eps1lon closed this as completed Aug 11, 2021
@eps1lon eps1lon added duplicate This issue or pull request already exists and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Aug 11, 2021
@sandroweb

This comment has been minimized.

@oliviertassinari oliviertassinari added the component: autocomplete This is the name of the generic UI component, not the React module! label Aug 21, 2021
@oliviertassinari
Copy link
Member

Duplicate of #21661

@oliviertassinari oliviertassinari marked this as a duplicate of #21661 Aug 21, 2021
@sandroweb
Copy link
Author

Duplicate of #21661

Is not duplicated, because #21661 is about position of the opened list. My problem is in dont lock the container scroll in the action of to open the list, like the select component. You was read my issue?

@nmchaves
Copy link
Contributor

nmchaves commented Oct 18, 2021

I think @sandroweb is right. This is different from #21661.

Sandro's point is that the Autocomplete component isn't consistent with the Select component right now. The Select component locks the body scroll, while the Autocomplete component does not.

In other words, you can scroll up and down the page even when an Autocomplete's listbox is open. IMO, it would be better if Autocomplete behaved like Select.

The video in the issue description shows the difference between Select and Autocomplete. In the first 10 seconds of the video, Sandro shows how you can't scroll when a Select menu is open. Then, at 0:15, Sandro shows how you can scroll when an Autocomplete is open.

I think the difference arises from the fact that Select builds on top of Modal (via Menu/Popover), whereas Autocomplete builds on top of Popper. Modal locks the scroll (unless disableScrollLock=true), but Popper doesn't lock the scroll.

Would it make sense to reopen this issue?

Edit: There is some discussion about this topic in #18136. See the 2nd item of #18136 (comment). So I think it would make sense for this issue to remain closed.

As an aside:
Thanks for such a terrific library! 🙏 MUI makes my life much better 😄

@damianobarbati
Copy link

@nmchaves this issue was closed but how can the problem be solved? How do we lock the outer scroll when Autocomplete is open? I still see this in @mui/material v5.14.7

@enoh-barbu
Copy link

enoh-barbu commented Jul 5, 2024

Just do it for yourself

const onOpen = () => {
    document.body.style.overflow = 'hidden';
    document.body.style.paddingRight = window.innerWidth - document.body.clientWidth
};

const onClose = () => {
    document.body.style.overflow = '';
    document.body.style.paddingRight = ''
};

onOpen={onOpen}
onClose={onClose}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: autocomplete This is the name of the generic UI component, not the React module! duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

6 participants