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] List scrolls to the top when new data is added (only on mobile) #36212

Closed
2 tasks done
PiotrJn opened this issue Feb 15, 2023 · 5 comments · Fixed by #36231
Closed
2 tasks done

[Autocomplete] List scrolls to the top when new data is added (only on mobile) #36212

PiotrJn opened this issue Feb 15, 2023 · 5 comments · Fixed by #36231
Labels
bug 🐛 Something doesn't work component: autocomplete This is the name of the generic UI component, not the React module!

Comments

@PiotrJn
Copy link

PiotrJn commented Feb 15, 2023

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Steps to reproduce 🕹

Link to live example:
https://codesandbox.io/embed/mui-autocomplete-bug-bjlczv

Steps:

  1. Open browser devtools and set view to mobile
  2. Open CodeSandbox
  3. Scroll down the autocomplete's options

Current behavior 😯

On mobile list scrolls to the top when new data is added

Expected behavior 🤔

Scroll position should stay the same

Context 🔦

I found an issue that intended to resolve this bug and it did, but only on desktop, mobile is still broken:
#29508

Your environment 🌎

"react": "18.2.0",
"react-dom": "18.2.0",
"react-scripts": "4.0.0",
"@mui/material": "5.11.9",
"@mui/styles": "5.11.9",
"@mui/system": "5.11.9",
"@emotion/react": "11.10.5",
"@emotion/styled": "11.10.5"
@PiotrJn PiotrJn added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Feb 15, 2023
@zannager zannager added the component: autocomplete This is the name of the generic UI component, not the React module! label Feb 16, 2023
@michaldudak
Copy link
Member

Thanks, I was able to reproduce it. Would you like to contribute to the project by investigating it?

@michaldudak michaldudak added bug 🐛 Something doesn't work and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Feb 16, 2023
@michaldudak michaldudak removed their assignment Feb 16, 2023
@PiotrJn
Copy link
Author

PiotrJn commented Feb 16, 2023

I looked at it and here's what's going on: current logic checks whether any previous option was highlighted when new options are added - if not, the scroll position is reset. On touch devices options are not highlighted when scrolling, unless you press them - that's the problem.

In this PR there is a discussion about that logic:
#33645

@SaidMarar
Copy link
Contributor

@michaldudak i identified the bug i will make a PR soon 😉

@SaidMarar
Copy link
Contributor

Created a PR check it out guys #36231

@michaldudak @PiotrJn

@PiotrJn
Copy link
Author

PiotrJn commented Feb 17, 2023

Thank You for the fix @SaidMarar, as for me, it looks great.

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: autocomplete This is the name of the generic UI component, not the React module!
Projects
None yet
4 participants